Cipher algorithm functions provide AES encryption and decryption, SHA-1 and SHA-2 hashing, HMAC computation, and MD5 digest calculation.
aes_new
| Item | Description |
| Syntax | aes_new(config) |
| Feature | Creates an AES object for subsequent encryption with aes_enc() and decryption with aes_dec(). |
| Parameter | The config parameter is of the dictionary type and includes the following arguments:
|
| Return value | Returns an AES object (dictionary type) on success, or false on failure. |
| Example | |
aes_enc
| Item | Description |
| Syntax | aes_enc(o, s) |
| Feature | Encrypts data with AES. |
| Parameter |
|
| Return value | Returns the ciphertext after encrypting the s parameter. |
| Example | |
aes_dec
| Item | Description |
| Syntax | aes_dec(o, s) |
| Feature | Decrypts AES-encrypted data. |
| Parameter |
|
| Return value | Returns the plaintext after decrypting the s parameter. |
| Example | |
sha1
| Item | Description |
| Syntax | sha1(s) |
| Feature | Calculates a SHA-1 hash. |
| Parameter | s: the string for which you want to calculate a hash digest. |
| Return value | Returns a SHA-1 hash in binary format. |
| Example |
Output:
|
sha2
| Item | Description |
| Syntax | sha2(s, l) |
| Feature | Calculates a SHA-2 hash. |
| Parameter |
|
| Return value | Returns a SHA-2 hash in binary format. |
| Example |
Output:
|
hmac
| Item | Description |
| Syntax | hmac(k, s, v) |
| Feature | Calculates an HMAC value. |
| Parameter |
|
| Return value | Returns an HMAC value in binary format. |
| Example |
Output:
|
hmac_sha1
| Item | Description |
| Syntax | hmac_sha1(k, s) |
| Feature | Calculates an HMAC-SHA-1 value. |
| Parameter |
|
| Return value | Returns an HMAC-SHA-1 value in binary format. |
| Example |
Output:
|
md5
| Item | Description |
| Syntax | md5(s) |
| Feature | Calculates an MD5 digest. |
| Parameter | s: the string for which you want to calculate a hash digest. |
| Return value | Returns an MD5 value in hexadecimal format. |
| Example |
Output:
|
md5_bin
| Item | Description |
| Syntax | md5_bin(s) |
| Feature | Calculates an MD5 digest. |
| Parameter | s: the string for which you want to calculate a hash digest. |
| Return value | Returns an MD5 digest in binary format. |
| Example |
Output:
|