Crypto Library



( ZN >= 3.0.0 )

The class that performs the encryption functions. The default values ​​for the vectors and keys used in encryption are derived from the value of the projectKey parameter in the Config / CryptoGraphy.php file . If you specify your own vector and key values, your personal configuration will be valid.

 

 

# Methods


String encrypt ( String $ data , Array $ settings = [] )
String decrypt ( String $ data , Array $ settings = [] )
String keygen ( Int $ length = 8 )
this driver ( String $ driver )

 

 

# Drivers


Listed below are available drivers for this library.

OpenSSL It is predefined.
mcrypt 7.2Removed in PHP version. 
hash Used for one-way encryption. decrypt()method.
mhash Used for one-way encryption. decrypt()method.
phash decrypt()and encrypt()methods.

 

 

# Encryption Configurations by Driver Tape


Below are the definitions that you can use for password configuration according to the selected driver type.

Openssl Driver [Default]
Cipher [Key Size] AES-128 [16]
Vector [Vector Size] ecb [0], rc2 [8], cbc [16]
Mcrypt Driver
Cipher [Key Size] 16], [16], [16], [3], [3], and Rajndael-192 [24], SaferPlus [24] , tripledes [24], cast-256 [32], gost, loki97 [32], rijndael-256 [32]
Mode ecb, cbc, cfb, ofb, nofb, stream
Vector [Vector Size] 256 [16], rifndael-192 [24], rijndael-256 [16], serpent [16], twofish [16], bc [8], cast-256 [16], loki97 [ 32]
Important: As of PHP 7.2 , the mCrypt  driver will not be supported.

 

 

# Encrypt ( ZN >= 3.0.0 )


Encrypt plain text with the given parameters.

Parameters
String $ data The data to be encrypted.
Array $ settings = [] Settings.
cipher One of the encryption constants is used according to the drive type.
the key The key to encrypt the data.
mode One of the encryption modes is used according to the drive type.
vector CBC , CFB , OFBmode and some algorithms in STREAM mode
return String
Use of
$encrypt = Crypto::encrypt('Example Data',
[
    'key'  => 'xxcv2151',
    'mode' => 'cbc'
]);

echo $encrypt;
/ yw / 2pwQFgwcotDEE9FYEQ == 

 

 

# Decrypt ( ZN >= 3.0.0 )


Used to decrypt the encrypted data.

Parameters
String $ data The data to be encrypted.
Array $ settings = [] Settings.
cipher MCRYPT_XXXThe XXX part of any of the constants is given as a string .
the key The key to encrypt the data.
mode MCRYPT_MODE_XXXThe XXX part of any of the constants is given as a string .
vector CBC , CFB , OFBmode and some algorithms in STREAM mode
return String
Use of
$encrypt = Crypto::encrypt('Example Data',
[
    'key'  => 'xxcv2151',
    'mode' => 'cbc'
]);

echo Crypto::decrypt($encrypt,
[
    'key'  => 'xxcv2151',
    'mode' => 'cbc'
]);
Example Data

 

 

# Keygen ( ZN >= 3.0.0 )


Used to generate a password for a specific length.

Parameters
Int $ length = 8 Password length.
return String
Use of
echo Crypto::keygen(7);

 

 

# Driver ( ZN> = 3.0.0 )


Used to change encryption drive.

Parameters
String $ Driver Drive name.
mcrypt , openssl , hash , phash , mhash
return String
Use of
\Output::writeLine( Crypto::keygen() );
\Output::writeLine( Crypto::driver('openssl')->keygen() );
\Output::writeLine( Crypto::driver('phash')->keygen() );
] M 2
? 7 n?
dgngz0ko