1
0
Fork 0
forked from fun/fun
fun/examples/md5_demo.fun

34 lines
936 B
Standard ML
Executable file

#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://hanez.org/project/fun/
*
* Copyright 2025 Johannes Findeisen <you@hanez.org>
* Licensed under the terms of the ISC license.
* https://opensource.org/license/isc-license-txt
*
* Added: 2025-09-29
*/
// Include the pure Fun MD5 library
include "lib/crypt/md5.fun"
// create a hasher instance
md5 = MD5()
print("=== MD5 demo (hex input) ===")
// "abc" => 0x61 0x62 0x63
print(md5.md5_hex("616263")) // -> 900150983cd24fb0d6963f7d28e17f72
// empty string "" => hex ""
print(md5.md5_hex("")) // -> d41d8cd98f00b204e9800998ecf8427e
// "message digest"
print(md5.md5_hex("6d65737361676520646967657374")) // -> f96b697d7cb7938d525a2f31aaf161d0
// "abcdefghijklmnopqrstuvwxyz"
print(md5.md5_hex("6162636465666768696a6b6c6d6e6f707172737475767778797a")) // -> c3fcd3d76192e4007dfb496cca67e13b
print("=== Done ===")