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.

While not as secure as SHA1, it is still used in many places for data integrity, version control, and other features that need unique one-way signatures.

MD5 Function

MD5 processes a variable-length message into a fixed-length output of 128 bits. The input message is broken up into chunks of 512-bit blocks (sixteen 32-bit words); the message is padded so that its length is divisible by 512. The padding works as follows: first a single bit, 1, is appended to the end of the message. This is followed by as many zeros as are required to bring the length of the message up to 64 bits fewer than a multiple of 512. The remaining bits are filled up with 64 bits representing the length of the original message, modulo 264.

MD5("The quick brown fox jumps over the lazy dog")
9e107d9d372bb6826bd81d3542a419d6

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

https://en.wikipedia.org/wiki/MD5

MultiValue BASIC Hashing

Most versions of MultiValue BASIC do not include built-in hashing functions. This requires developers to create their own. We can use Pure/Generic MultiValue BASIC, but you may see a performance hit depending on how bit math is handled. For hash values like MD5, the performance issues of generic bit math does not seem to be a problem.

Dave Meagher has done all the work to provide hash functions like SHA1 and MD5 in his FOSS4MV/mvCrypt code on BitBucket:

https://bitbucket.org/foss4mv/mvcrypt

The IS.HASH.MD5 program attached to this article used Dave's mvCrypt MD5 code, but formats it so that it is interchangeable with other versions of the IS.HASH.MD5 code on the International Spectrum Website.

Example

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

Output

9e107d9d372bb6826bd81d3542a419d6 = 9e107d9d372bb6826bd81d3542a419d6 - Ok 

Nathan Rector

Nathan Rector, President of International Spectrum, has been in the MultiValue marketplace as a consultant, author, and presenter since 1992. As a consultant, Nathan specialized in integrating MultiValue applications with other devices and non-MultiValue data, structures, and applications into existing MultiValue databases. During that time, Nathan worked with PDA, Mobile Device, Handheld scanners, POS, and other manufacturing and distribution interfaces.

In 2006, Nathan purchased International Spectrum Magazine and Conference and has been working with the MultiValue Community to expand its reach into current technologies and markets. During this time he has been providing mentorship training to people converting Console Applications (Green Screen/Text Driven) to GUI (Graphical User Interfaces), Mobile, and Web. He has also been working with new developers to the MultiValue Marketplace to train them in how MultiValue works and acts, as well as how it differs from the traditional Relational Database Model (SQL).

View more articles

Featured:

Jan/Feb 2017

menu
menu