Guest User

Untitled

a guest
Jan 24th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. <?php
  2.  
  3. function my_custom_gravityforms_encrypt( $to_encrypt )
  4. {
  5. if ( '' === $to_encrypt ) return null;
  6.  
  7. if ( function_exists('openssl_encrypt') && function_exists('openssl_random_pseudo_bytes') )
  8. {
  9. $iv = openssl_random_pseudo_bytes( openssl_cipher_iv_length( 'aes-256-cbc' ) );
  10. $encrypted = openssl_encrypt( $to_encrypt, 'aes-256-cbc', MY_CUSTOM_GF_ENCRYPTION_KEY, 0, $iv );
  11.  
  12. return base64_encode( $encrypted . '::' . $iv );
  13. }
  14.  
  15. return base64_encode( $to_encrypt );
  16. } // end my_custom_gravityforms_encrypt
  17.  
  18.  
  19.  
  20. function my_custom_gravityforms_decrypt( $to_decrypt )
  21. {
  22. if ( '' === $to_decrypt ) return null;
  23.  
  24. if ( function_exists('openssl_decrypt') )
  25. {
  26. @list( $encrypted_data, $iv ) = explode( '::', base64_decode( $to_decrypt ), 2 );
  27.  
  28. return openssl_decrypt( $encrypted_data, 'aes-256-cbc', MY_CUSTOM_GF_ENCRYPTION_KEY, 0, $iv );
  29. }
  30.  
  31. return base64_decode( $to_decrypt );
  32. } // end my_custom_gravityforms_decrypt
Add Comment
Please, Sign In to add comment