crypt() public static method

Perform (en/de)cryption
public static crypt ( string $str, string $key ) : string
$str string String to be encrypted
$key string Key to use for encryption
return string
Beispiel #1
0
 public function testCrypt()
 {
     $input = 'AAAAAAAA';
     $key = openssl_random_pseudo_bytes(32);
     /*
      * Test encryption
      */
     $encrypted = Spritz::crypt($input, $key);
     $this->assertEquals(strlen($input), strlen($encrypted));
     $this->assertNotEquals($input, $encrypted);
     /*
      * Test decryption
      */
     $decrypted = Spritz::crypt($encrypted, $key);
     $this->assertEquals($input, $decrypted);
 }