createFromKey() public static method

Initializes an instance of KeyOrPassword from a key.
public static createFromKey ( Defuse\Crypto\Key $key ) : KeyOrPassword
$key Defuse\Crypto\Key
return KeyOrPassword
コード例 #1
0
ファイル: Crypto.php プロジェクト: defuse/php-encryption
 /**
  * Decrypts a ciphertext to a string with a Key.
  *
  * @param string $ciphertext
  * @param Key    $key
  * @param bool   $raw_binary
  *
  * @throws Ex\EnvironmentIsBrokenException
  * @throws Ex\WrongKeyOrModifiedCiphertextException
  *
  * @return string
  */
 public static function decrypt($ciphertext, Key $key, $raw_binary = false)
 {
     return self::decryptInternal($ciphertext, KeyOrPassword::createFromKey($key), $raw_binary);
 }
コード例 #2
0
ファイル: File.php プロジェクト: twistor/php-encryption
 /**
  * Takes two resource handles and decrypts the contents of the first,
  * writing the plaintext into the second.
  *
  * @param resource $inputHandle
  * @param resource $outputHandle
  * @param Key      $key
  *
  * @throws Defuse\Crypto\Exception\EnvironmentIsBrokenException
  * @throws Defuse\Crypto\Exception\IOException
  * @throws Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException
  */
 public static function decryptResource($inputHandle, $outputHandle, Key $key)
 {
     self::decryptResourceInternal($inputHandle, $outputHandle, KeyOrPassword::createFromKey($key));
 }