plainEncrypt() защищенный статический Метод

Raw unauthenticated encryption (insecure on its own).
protected static plainEncrypt ( string $plaintext, string $key, string $iv ) : string
$plaintext string
$key string
$iv string
Результат string
Пример #1
0
 /**
  * Test AES against test vectors.
  *
  * @throws Ex\EnvironmentIsBrokenException
  */
 private static function AESTestVector()
 {
     // AES CTR mode test vector from NIST SP 800-38A
     $key = Encoding::hexToBin('603deb1015ca71be2b73aef0857d7781' . '1f352c073b6108d72d9810a30914dff4');
     $iv = Encoding::hexToBin('f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff');
     $plaintext = Encoding::hexToBin('6bc1bee22e409f96e93d7e117393172a' . 'ae2d8a571e03ac9c9eb76fac45af8e51' . '30c81c46a35ce411e5fbc1191a0a52ef' . 'f69f2445df4f9b17ad2b417be66c3710');
     $ciphertext = Encoding::hexToBin('601ec313775789a5b7a7f504bbf3d228' . 'f443e3ca4d62b59aca84e990cacaf5c5' . '2b0930daa23de94ce87017ba2d84988d' . 'dfc9c58db67aada613c2dd08457941a6');
     $computed_ciphertext = Crypto::plainEncrypt($plaintext, $key, $iv);
     if ($computed_ciphertext !== $ciphertext) {
         echo \str_repeat("\n", 30);
         echo \bin2hex($computed_ciphertext);
         echo "\n---\n";
         echo \bin2hex($ciphertext);
         echo \str_repeat("\n", 30);
         throw new Ex\EnvironmentIsBrokenException();
     }
     $computed_plaintext = Crypto::plainDecrypt($ciphertext, $key, $iv, Core::CIPHER_METHOD);
     if ($computed_plaintext !== $plaintext) {
         throw new Ex\EnvironmentIsBrokenException();
     }
 }