Welcome Guest | My Membership | Login

IS.HASH.SHA1: Generating with UniBASIC DIGEST command


Downloads

Article

In cryptography, SHA-1 (Secure Hash Algorithm 1) is a cryptographic hash function designed by the United States National Security Agency and is a U.S. Federal Information Processing Standard published by the United States NIST. SHA1 is used in many places to generate a unique hash value representing a string or file. It is widely used in place of MD4 and MD5 hash as a more secure hash value. While not as secure as SHA256, it is still used in many places for data integrity, version control, and other features that need an unique one-way signatures.

SHA1 Function

SHA-1 produces a 160-bit (20-byte) hash value known as a message digest. A SHA-1 hash value is typically rendered as a hexadecimal number, 40 digits long.

SHA1("The quick brown fox jumps over the lazy dog")

gives hexadecimal:

2fd4e1c67a2d28fced849ee1bb76e7391b93eb12

SHA1 will detect even small changes in the string and cause the returned hash value to change. You can always read more about SHA1 at:

https://en.wikipedia.org/wiki/SHA-1

UniBASIC Hashing

UniBASIC comes with hashing extensions in the form of DIGEST(). The DIGEST has SHA1 built-in. This allows you to use code like the example below.

SHA1.MESSAGE = "The quick brown fox jumps over the lazy dog"
ret = DIGEST('SHA1',SHA1.MESSAGE, 1, SHA1.HASH)
CRT SHA1.HASH : ' = 2fd4e1c67a2d28fced849ee1bb76e7391b93eb12

The subroutine found with this article is based on the code above, but has been structured to be interchangeable with non-UniBASIC versions of the SHA1 subroutine also found on the International Spectrum Website at: http://www.intl-spectrum.com/resource/756/default.aspx.

Example

SHA1.MESSAGE = "The quick brown fox jumps over the lazy dog"
CALL IS.HASH.SHA1(SHA1.MESSAGE,HASH.VALUE)
*
TEST.VALUE = "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12"
CRT HASH.VALUE : " =" : TEST.VALUE :" - "
IF (HASH.VALUE EQ TEST.VALUE) THEN
  CRT "Ok"
END ELSE
  CRT "Failed"
END

Output

2fd4e1c67a2d28fced849ee1bb76e7391b93eb12 = 2fd4e1c67a2d28fced849ee1bb76e7391b93eb12 - Ok

 

# # #          # # #          # # #

 

Related Articles

  • IS.HASH.HMACSHA1: Generating HMAC-SHA1 Values with Generic MultiValue BASIC

    Database: UniData, UniVerse

    The Message Authentication Code (MAC) is a widely used technique for performing message authentication. HMAC (short for "keyed-Hashing for Message Authentication"), a variation on the MAC algorithm, has emerged as an Internet standard for a variety of applications.

  • IS.HASH.SHA1: Generating SHA1 values with Generic MultiValue BASIC

    In cryptography, SHA-1 (Secure Hash Algorithm 1) is a cryptographic hash function designed by the United States National Security Agency and is a U.S. Federal Information Processing Standard published by the United States NIST. SHA1 is used in many places to generate a unique Hash value representing a string or file. It is widely used in place of MD4 and MD5 ash a more secure hash value. While not as secure as SHA256, it is still used in many places for data integrity, version control, and other features that need an unique one-way signatures.

  • IS.HASH.MD5 Generating MD5 Values with Generic MultiValue BASIC

    The MD5 message-digest algorithm is a widely used cryptographic hash function producing a 128-bit (16-byte) hash value, typically expressed in text format as a 32-digit hexadecimal number. MD5 has been utilized in a wide variety of cryptographic applications and is also commonly used to verify data integrity.

  • IS.HASH.SHA1: Generating SHA1 Values with Generic MultiValue BASIC

    In cryptography, SHA-1 (Secure Hash Algorithm 1) is a cryptographic hash function designed by the United States National Security Agency and is a U.S. Federal Information Processing Standard published by the United States NIST. SHA1 is used in many places to generate a unique Hash value representing a string or file. It is widely used in place of MD4 and MD5 hash because it has a more secure hash value. While not as secure as SHA256, it is still used in many places for data integrity, version control, and other features that need unique one-way signatures.

  • IS.UUID.V1 UUID V1 Time Based Generation

    A Universally Unique Identifier (UUID) is an identifier standard used in many non-MultiValue databases and software to generate a Unique Id outside of using incremental numbers. A UUID is simply a 128-bit unique value that can be expressed as either a larger number, or a string.


Return to top