Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. // Методы
  2. function encrypt($message)
  3. {
  4. // Ключ
  5. $AES_Key256 = '28937539283712098445739080393827';
  6.  
  7. // Вектор
  8. $AES_IV = '8574930392882739';
  9.  
  10. // Алгоритм шифрования
  11. $cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
  12.  
  13. if (mcrypt_generic_init($cipher, $AES_Key256, $AES_IV) != -1)
  14. {
  15. $cipherText = mcrypt_generic($cipher, addpadding($message));
  16. mcrypt_generic_deinit($cipher);
  17. return base64_encode($cipherText);
  18. }
  19. }
  20.  
  21. function addpadding($string, $blocksize = 16)
  22. {
  23. $len = strlen($string);
  24. $pad = $blocksize - ($len % $blocksize);
  25. $string .= str_repeat(chr($pad), $pad);
  26. return $string;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement