decrypt() публичный Метод

Decrypts data with {@link getEncryptionKey EncryptionKey}.
public decrypt ( $data ) : string
Результат string the decrypted data
Пример #1
0
 public function testEncryptDecrypt()
 {
     $sec = new TSecurityManager();
     $sec->init(null);
     // loop through different string size
     $testText = md5('a text (not) full of entrophy');
     for ($i = 1; $i < strlen($testText); $i++) {
         $sec->setEncryptionKey('aKey');
         $plainText = substr($testText, 0, $i);
         try {
             $encrypted = $sec->encrypt($plainText);
         } catch (TNotSupportedException $e) {
             self::markTestSkipped('mcrypt extension not loaded');
             return;
         }
         $decrypted = $sec->decrypt($encrypted);
         // the decrypted string is padded with \0
         $decrypted = strstr($decrypted, "", TRUE);
         self::assertEquals($plainText, $decrypted);
         // try change key
         $sec->setEncryptionKey('anotherKey');
         self::assertNotEquals($plainText, $sec->decrypt($encrypted));
     }
 }