MD5$: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 17: Line 17:
* Historically it was widely used as a cryptographic hash function, however it has been found to suffer from extensive vulnerabilities.
* Historically it was widely used as a cryptographic hash function, however it has been found to suffer from extensive vulnerabilities.
* It remains suitable for other non-cryptographic purposes and may be preferred due to lower computational requirements than more recent Secure Hash Algorithms.
* It remains suitable for other non-cryptographic purposes and may be preferred due to lower computational requirements than more recent Secure Hash Algorithms.
;Attention when comparing hashes
:* MD5 hashes may contain the hexadecimal letters A-F and implementations may differ using either lower or upper case letters.
:* If you compare hashes from external sources, which were not generated with our '''_MD5$''' function, then make sure to use either [[LCASE$]] or [[UCASE$]] on all hashes to avoid mismatches due to case differences.
:* Our function will always return upper case.




Line 29: Line 33:
File:Osx.png|'''yes'''
File:Osx.png|'''yes'''
</gallery>
</gallery>
<!-- Additional availability notes go below the gallery -->
<!-- additional availability notes go below here -->




Line 41: Line 45:
{{Cl|PRINT}}
{{Cl|PRINT}}
{{Text|<nowiki>'this text differs in just 1 bit from the above, by changing 4 to 5</nowiki>|#919191}}
{{Text|<nowiki>'this text differs in just 1 bit from the above, by changing 4 to 5</nowiki>|#919191}}
{{Text|<nowiki>'ASC("4") = 52 = &B00110100</nowiki>|#919191}}
{{Text|<nowiki>'ASC("4") = 52 = &amp;B00110100</nowiki>|#919191}}
{{Text|<nowiki>'ASC("5") = 53 = &B00110101</nowiki>|#919191}}
{{Text|<nowiki>'ASC("5") = 53 = &amp;B00110101</nowiki>|#919191}}
t$ = {{Text|<nowiki>"QB65 Phoenix Edition"</nowiki>|#FFB100}}
t$ = {{Text|<nowiki>"QB65 Phoenix Edition"</nowiki>|#FFB100}}
{{Cl|PRINT}} {{Text|<nowiki>"Mangled Text: "</nowiki>|#FFB100}}; t$
{{Cl|PRINT}} {{Text|<nowiki>"Mangled Text: "</nowiki>|#FFB100}}; t$

Latest revision as of 01:06, 2 February 2025

The _MD5$ function returns the MD5 hash value of any arbitrary string.


Syntax

md5hash$ = _MD5$(dataString$)


Parameters

  • md5hash$ is the hash value returned as hexadecimal STRING, if the given dataString$ was empty the unusual but absolutely correct hash value is:
    • D41D8CD98F00B204E9800998ECF8427E
  • dataString$ is any literal or variable STRING to build the hash value from.


Description

  • MD5 can be used as a checksum to verify data integrity against unintentional corruption.
  • Historically it was widely used as a cryptographic hash function, however it has been found to suffer from extensive vulnerabilities.
  • It remains suitable for other non-cryptographic purposes and may be preferred due to lower computational requirements than more recent Secure Hash Algorithms.
Attention when comparing hashes
  • MD5 hashes may contain the hexadecimal letters A-F and implementations may differ using either lower or upper case letters.
  • If you compare hashes from external sources, which were not generated with our _MD5$ function, then make sure to use either LCASE$ or UCASE$ on all hashes to avoid mismatches due to case differences.
  • Our function will always return upper case.


Availability


Examples

Example
Showing how the MD5 hash value can detect differences in two strings.
'this is the correct text
t$ = "QB64 Phoenix Edition"
PRINT "Correct Text: "; t$
PRINT "    MD5 hash: "; _MD5$(t$)
PRINT
'this text differs in just 1 bit from the above, by changing 4 to 5
'ASC("4") = 52 = &B00110100
'ASC("5") = 53 = &B00110101
t$ = "QB65 Phoenix Edition"
PRINT "Mangled Text: "; t$
PRINT "    MD5 hash: "; _MD5$(t$)
END
Example by RhoSigma
Correct Text: QB64 Phoenix Edition
    MD5 hash: E512ECA19E9487D7C2F564E848314238

Mangled Text: QB65 Phoenix Edition
    MD5 hash: 3EF03E7B0DB46F7D1FA6B9626563C10B


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link