Derive an encryption key (symmetric-key cryptography) from a password
and salt
public static deriveEncryptionKey ( |
||
$password | ||
$salt | string | |
$level | string | Security level for KDF |
리턴 | EncryptionKey |
public function testLegacyDerive() { $key = KeyFactory::deriveEncryptionKey('apple', "\t\n\v\f\r" . "", true); $this->assertEquals($key->getRawKeyMaterial(), "6�¹je\r��~^X��" . "63�u��7�B�TX-", true); $salt = \Sodium\hex2bin('762ce4cabd543065172236de1027536ad52ec4c9133ced3766ff319f10301888'); // Issue #10 $enc_secret = KeyFactory::deriveEncryptionKey('correct horse battery staple', $salt, Key::ENCRYPTION | Key::SECRET_KEY); $this->assertTrue($enc_secret->isEncryptionKey()); }