Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  1. <?php
  2.  
  3. class Aes128CBCEncryptor
  4. {
  5.     const METHOD = 'aes-128-cbc';
  6.     const BLOCK_SIZE = 16;
  7.     const KEY_TOKEN = 'klucz szyfrujacy';
  8.     const IV = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
  9.  
  10.     public static function getKey()
  11.     {
  12.         return sha1(self::KEY_TOKEN);
  13.     }
  14.  
  15.     public static function encrypt($text)
  16.     {
  17.         return openssl_encrypt($text, self::METHOD, self::getKey(), OPENSSL_RAW_DATA, self::IV);
  18.     }
  19.  
  20.     public static function decrypt($text)
  21.     {
  22.         return openssl_decrypt($text, self::METHOD, self::getKey(),OPENSSL_RAW_DATA, self::IV);
  23.     }
  24.  
  25.     public static function paddingOracleCheck($cipheredText)
  26.     {
  27.         $text = self::decrypt($cipheredText);
  28.         return boolval($text);
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement