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