Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $key = "mySecretKey";
- $cipher = "aes-128-gcm";
- $ivlen = openssl_cipher_iv_length($cipher);
- $iv = openssl_random_pseudo_bytes($ivlen);
- $ciphertext = openssl_encrypt("message to be encrypted", $cipher, $key, $options=0, $iv, $tag);
- $original_plaintext = openssl_decrypt($ciphertext, $cipher, $key, 0, $iv, $tag);
- echo "original message: ".$original_plaintext."n";
- // $iv and $tag change each time we encrypt the data, so store these
- ?>
Add Comment
Please, Sign In to add comment