initial commit

This commit is contained in:
Luke Ogburn
2019-03-30 23:03:43 -04:00
commit 3d9e0c7717
29 changed files with 740 additions and 0 deletions

17
enc.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
function encrypt($plaintext, $key){
$cipher = "aes-128-gcm";
if (in_array($cipher, openssl_get_cipher_methods())){
$ivlen = openssl_cipher_iv_length($cipher);
$iv = openssl_random_pseudo_bytes($ivlen);
$res = openssl_encrypt($plaintext, $cipher, $key, $options=0, $iv, $tag);
return array($res, $iv, $tag);
}
}
function decrypt($ciphertext, $key, $iv, $tag){
$cipher = "aes-128-gcm";
if (in_array($cipher, openssl_get_cipher_methods())){
return openssl_decrypt($ciphertext, $cipher, $key, $options=0, $iv, $tag);
}
}
?>