Re: Checksums, hashes, and digests, oh my!
- Posted by ghaberek (admin) Jan 18, 2022
- 1303 views
What are these for?
Cryptographic hash functions are used to verify the integrity or content of messages and files. They're typically used to store a one-way hash for validating passwords, or to check the integrity of a downloaded file.
How will they benefit an average Euser?
This is one of those features that nearly anyone can and should be using when needed. Providing a standard, base-line implementation ensures most users don't have to hunt for code and re-invent the wheel.
Will a name change break a lot of stuff?
I don't think so. We can accommodate the change in the standard library so std/map.e, etc. aren't affected and then mark hash() as deprecated in std/hash.e and then we can remove it entirely in a later version.
So std/hash.e would end up looking something like this:
constant M_CHECKSUM = 98, M_CALCHASH = 99 public enum ADLER32, FLETCHER32, ... deprecate -- this will issue a warning if still used public function hash( object data_in, integer algo ) return machine_func( M_CHECKSUM, {data_in,algo} ) end function public function checksum( object data_in, integer algo ) return machine_func( M_CHECKSUM, {data_in,algo} ) end function public function adler32( object data_in ) return machine_func( M_CHECKSUM, {data_in,ADLER32} ) end function public function fletcher32( object data_in ) return machine_func( M_CHECKSUM, {data_in,FLETCHER32} ) end function -- etc. public enum MD5, SHA1, SHA256, ... public function calc_hash( sequence data_in, integer algo ) return machine_func( M_CALCHASH, {data_in,algo} ) end function public function md5sum( sequence data_in ) return machine_func( M_CALCHASH, {data_in,MD5} ) end function public function sha1sum( sequence data_in ) return machine_func( M_CALCHASH, {data_in,SHA1} ) end function -- etc.
There are plenty more algorithms that we could implement, but I think when we go from "common message digests" to "actual data cryptography" we should focus on providing an external library.
-Greg

