Does Universe have a function to encrypt a string with sha256 using a secret key.
------------------------------
[Gary] [Rhodes]
[Universe Developer]
[NPW Companies]
[Hialeah] [FL] [USA]
------------------------------
Does Universe have a function to encrypt a string with sha256 using a secret key.
Does Universe have a function to encrypt a string with sha256 using a secret key.
Hi Gary,
Yes UniVerse and UniData do, please see the documentation on the HMAC function. It was added in 8.2.1 of UniData and 11.3.1 of UniVerse.
HMAC function
HMAC (keyed-Hash Message Authentication Code) is a specific construction for calculating a message authentication code (MAC) involving a cryptographic hash function in combination with a secret key.
Note: The HMAC function is in full compliance with RFC 2104.
Syntax
hmac= HMAC(hmacAlg, hmacKey, hmacData, [outFormat])
hmacAlg, hmacKey, and hmacData are string values. They can be supplied as quoted strings or as string variables, or a mix of both.
Parameters
The following table describes each parameter of the syntax.
hmacAlg Any OpenSSL supported digest functions, such as MD5, SHA1, SHA256, SHA384, or SHA512. If FIPS mode is turned on, only FIPS-compliant digest algorithms are allowed (namely SHA1, SHA256,SHA384 and SHA512).
hmacKey User must take responsibility to keep this key secure.
hmacData Data for which a keyed hash is to be generated by the HMAC function.
outformat Optional. Determines the output format. Currently, the following values are supported:
0 - The output is binary format (bit-stream)
1 - Lower case hexadecimal format, for example f22a....0def, which doubles the size of binary format
2 - Uppercase hexadecimal format, for example F22A...0DEF
3 - Lowercase hexadecimal delimited by colons, for example f2:2a:...0d:ef
4 - Uppercase hexadecimal delimited by colons, for example F1:2A:...0D:EF
5 - Lowercase hexadecimal delimited by spaces, for example f2 2a ... 0d ef
6 - Uppercase hexadecimal delimited by spaces, for example F2 2A ... 0D EF
Return codes
The function returns hmac as the result, whose length is determined by the digest algorithm. For example, for MD5, the length is 16 bytes. For SHA1, it is 20 bytes. For SHA256, it is 32 bytes. All lengths are for binary format.
If an error occurs, the function will return -1. STATUS() can be called to determine the error details.
The following table describes the status of each return code.
Return code Status
0 Success.
1 Unsupported digest algorithm.
2 Not applicable.
3 HMAC cannot be obtained.
4 Invalid parameters.
Regards,
Jonathan
------------------------------
Jonathan Smith
UniData ATS
Rocket Support
------------------------------
Hi Gary,
Yes UniVerse and UniData do, please see the documentation on the HMAC function. It was added in 8.2.1 of UniData and 11.3.1 of UniVerse.
HMAC function
HMAC (keyed-Hash Message Authentication Code) is a specific construction for calculating a message authentication code (MAC) involving a cryptographic hash function in combination with a secret key.
Note: The HMAC function is in full compliance with RFC 2104.
Syntax
hmac= HMAC(hmacAlg, hmacKey, hmacData, [outFormat])
hmacAlg, hmacKey, and hmacData are string values. They can be supplied as quoted strings or as string variables, or a mix of both.
Parameters
The following table describes each parameter of the syntax.
hmacAlg Any OpenSSL supported digest functions, such as MD5, SHA1, SHA256, SHA384, or SHA512. If FIPS mode is turned on, only FIPS-compliant digest algorithms are allowed (namely SHA1, SHA256,SHA384 and SHA512).
hmacKey User must take responsibility to keep this key secure.
hmacData Data for which a keyed hash is to be generated by the HMAC function.
outformat Optional. Determines the output format. Currently, the following values are supported:
0 - The output is binary format (bit-stream)
1 - Lower case hexadecimal format, for example f22a....0def, which doubles the size of binary format
2 - Uppercase hexadecimal format, for example F22A...0DEF
3 - Lowercase hexadecimal delimited by colons, for example f2:2a:...0d:ef
4 - Uppercase hexadecimal delimited by colons, for example F1:2A:...0D:EF
5 - Lowercase hexadecimal delimited by spaces, for example f2 2a ... 0d ef
6 - Uppercase hexadecimal delimited by spaces, for example F2 2A ... 0D EF
Return codes
The function returns hmac as the result, whose length is determined by the digest algorithm. For example, for MD5, the length is 16 bytes. For SHA1, it is 20 bytes. For SHA256, it is 32 bytes. All lengths are for binary format.
If an error occurs, the function will return -1. STATUS() can be called to determine the error details.
The following table describes the status of each return code.
Return code Status
0 Success.
1 Unsupported digest algorithm.
2 Not applicable.
3 HMAC cannot be obtained.
4 Invalid parameters.
Regards,
Jonathan
------------------------------
Jonathan Smith
UniData ATS
Rocket Support
------------------------------
Hey Jonathan:
That worked completely as expected and will work for us. Interestingly two other generators from the web gave different results but this one works well.
Thank you!
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.