This topic describes the syntax, description, parameters, and return values of cipher algorithm functions. This topic also provides examples of these functions.
aes_new
The following table describes the details about this function.
Item | Description |
---|---|
Syntax | aes_new(config)
|
Description | Creates an Advanced Encryption Standard (AES) object, which is used for the subsequent
encryption and decryption operations. To perform an encryption, call the aes_enc() function. To perform a decryption, call the aes_dec() function.
|
Parameter | The config parameter is of the dictionary type and includes the following arguments:
|
Return value | If the function succeeds, an AES object (dictionary type) is returned. Otherwise,false is returned.
|
Example |
|
aes_enc
The following table describes the details about this function.
Item | Description |
---|---|
Syntax | aes_enc(o, s)
|
Description | Encrypts data by using the AES encryption algorithm. |
Parameter |
|
Return value | Returns the ciphertext after the text specified by the s parameter is encrypted.
|
Example |
|
aes_dec
The following table describes the details about this function.
Item | Description |
---|---|
Syntax | aes_dec(o, s)
|
Description | Decrypts data by using the AES encryption algorithm. |
Parameter |
|
Return value | Returns the plaintext after the text specified by the s parameter is decrypted.
|
Example |
|
sha1
The following table describes the details about this function.
Item | Description |
---|---|
Syntax | sha1(s)
|
Description | Calculates an SHA-1 value. |
Parameter | s: the string for which you want to calculate a CRC digest. |
Return value | Returns an SHA-1 value in binary format. |
Example |
|
sha2
The following table describes the details about this function.
Item | Description |
---|---|
Syntax | sha2(s, l)
|
Description | Calculates an SHA-2 value. |
Parameter |
|
Return value | Returns an SHA-2 value in binary format. |
Example |
|
hmac
The following table describes the details about this function.
Item | Description |
---|---|
Syntax | hmac(k, s, v)
|
Description | Calculates an HMAC value. |
Parameter |
|
Return value | Returns an HMAC value in binary format by using the corresponding algorithm. |
Example |
|
hmac_sha1
The following table describes the 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
The following table describes the details about this function.
Item | Description |
---|---|
Syntax | md5(s)
|
Description | Calculates an MD5 digest. |
Parameter | s: the string for which you want to calculate a CRC digest. |
Return value | Returns an MD5 value in hexadecimal format. |
Example |
|
md5_bin
The following table describes the details about this function.
Item | Description |
---|---|
Syntax | md5_bin(s)
|
Description | Calculates an MD5 digest. |
Parameter | s: the string for which you want to calculate a CRC digest. |
Return value | Returns an MD5 digest in binary format. |
Example |
|