Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function my_custom_gravityforms_encrypt( $to_encrypt )
- {
- if ( '' === $to_encrypt ) return null;
- if ( function_exists('openssl_encrypt') && function_exists('openssl_random_pseudo_bytes') )
- {
- $iv = openssl_random_pseudo_bytes( openssl_cipher_iv_length( 'aes-256-cbc' ) );
- $encrypted = openssl_encrypt( $to_encrypt, 'aes-256-cbc', MY_CUSTOM_GF_ENCRYPTION_KEY, 0, $iv );
- return base64_encode( $encrypted . '::' . $iv );
- }
- return base64_encode( $to_encrypt );
- } // end my_custom_gravityforms_encrypt
- function my_custom_gravityforms_decrypt( $to_decrypt )
- {
- if ( '' === $to_decrypt ) return null;
- if ( function_exists('openssl_decrypt') )
- {
- @list( $encrypted_data, $iv ) = explode( '::', base64_decode( $to_decrypt ), 2 );
- return openssl_decrypt( $encrypted_data, 'aes-256-cbc', MY_CUSTOM_GF_ENCRYPTION_KEY, 0, $iv );
- }
- return base64_decode( $to_decrypt );
- } // end my_custom_gravityforms_decrypt
Add Comment
Please, Sign In to add comment