Advertisement
Guest User

CSRF

a guest
Jun 15th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. function simpleCrypt( $string, $action = 'e' ) {
  2. // you may change these values to your own
  3. $secret_key = 'my_simple_secret_key';
  4. $secret_iv = 'my_simple_secret_iv';
  5.  
  6. $output = false;
  7. $encrypt_method = "AES-256-CBC";
  8. $key = hash( 'sha256', $secret_key );
  9. $iv = substr( hash( 'sha256', $secret_iv ), 0, 16 );
  10.  
  11. if( $action == 'e' ) {
  12. $output = base64_encode( openssl_encrypt( $string, $encrypt_method, $key, 0, $iv ) );
  13. }
  14. else if( $action == 'd' ){
  15. $output = openssl_decrypt( base64_decode( $string ), $encrypt_method, $key, 0, $iv );
  16. }
  17.  
  18. return $output;
  19. }
  20.  
  21. //echo time();
  22. function encrypt(){
  23. date_default_timezone_set('GMT');
  24. $now = date('m/d/Y h:i:s a', time());
  25.  
  26. $oneMoreHourFromNow = date('Y-m-d H:i',strtotime('+3 hour',strtotime($now)));
  27. $token = strtotime($oneMoreHourFromNow);
  28. //echo $timeFormat;
  29.  
  30. return simpleCrypt($token, 'e');
  31. }
  32. function decrypt($token){
  33. return simpleCrypt($token, 'd');
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement