PHP Class Defuse\Crypto\Crypto

Exibir arquivo Open project: defuse/php-encryption Class Usage Examples

Public Methods

Method Description
decrypt ( string $ciphertext, Defuse\Crypto\Key $key, boolean $raw_binary = false ) : string Decrypts a ciphertext to a string with a Key.
decryptWithPassword ( string $ciphertext, string $password, boolean $raw_binary = false ) : string Decrypts a ciphertext to a string with a password, using a slow key derivation function to make password cracking more expensive.
encrypt ( string $plaintext, Defuse\Crypto\Key $key, boolean $raw_binary = false ) : string Encrypts a string with a Key.
encryptWithPassword ( string $plaintext, string $password, boolean $raw_binary = false ) : string Encrypts a string with a password, using a slow key derivation function to make password cracking more expensive.
legacyDecrypt ( string $ciphertext, string $key ) : string Decrypts a legacy ciphertext produced by version 1 of this library.

Protected Methods

Method Description
plainDecrypt ( string $ciphertext, string $key, string $iv, string $cipherMethod ) : string Raw unauthenticated decryption (insecure on its own).
plainEncrypt ( string $plaintext, string $key, string $iv ) : string Raw unauthenticated encryption (insecure on its own).
verifyHMAC ( string $correct_hmac, string $message, string $key ) : boolean Verifies an HMAC without leaking information through side-channels.

Private Methods

Method Description
decryptInternal ( string $ciphertext, KeyOrPassword $secret, boolean $raw_binary ) : string Decrypts a ciphertext to a string with either a key or a password.
encryptInternal ( string $plaintext, KeyOrPassword $secret, boolean $raw_binary ) : string Encrypts a string with either a key or a password.

Method Details

decrypt() public static method

Decrypts a ciphertext to a string with a Key.
public static decrypt ( string $ciphertext, Defuse\Crypto\Key $key, boolean $raw_binary = false ) : string
$ciphertext string
$key Defuse\Crypto\Key
$raw_binary boolean
return string

decryptWithPassword() public static method

Decrypts a ciphertext to a string with a password, using a slow key derivation function to make password cracking more expensive.
public static decryptWithPassword ( string $ciphertext, string $password, boolean $raw_binary = false ) : string
$ciphertext string
$password string
$raw_binary boolean
return string

encrypt() public static method

Encrypts a string with a Key.
public static encrypt ( string $plaintext, Defuse\Crypto\Key $key, boolean $raw_binary = false ) : string
$plaintext string
$key Defuse\Crypto\Key
$raw_binary boolean
return string

encryptWithPassword() public static method

Encrypts a string with a password, using a slow key derivation function to make password cracking more expensive.
public static encryptWithPassword ( string $plaintext, string $password, boolean $raw_binary = false ) : string
$plaintext string
$password string
$raw_binary boolean
return string

legacyDecrypt() public static method

Decrypts a legacy ciphertext produced by version 1 of this library.
public static legacyDecrypt ( string $ciphertext, string $key ) : string
$ciphertext string
$key string
return string

plainDecrypt() protected static method

Raw unauthenticated decryption (insecure on its own).
protected static plainDecrypt ( string $ciphertext, string $key, string $iv, string $cipherMethod ) : string
$ciphertext string
$key string
$iv string
$cipherMethod string
return string

plainEncrypt() protected static method

Raw unauthenticated encryption (insecure on its own).
protected static plainEncrypt ( string $plaintext, string $key, string $iv ) : string
$plaintext string
$key string
$iv string
return string

verifyHMAC() protected static method

Verifies an HMAC without leaking information through side-channels.
protected static verifyHMAC ( string $correct_hmac, string $message, string $key ) : boolean
$correct_hmac string
$message string
$key string
return boolean