1
0
Fork 0
forked from fun/fun

File path refactoring. No code changes. (0.37.51)

This commit is contained in:
Johannes Findeisen 2026-01-14 04:02:24 +01:00
commit db68b30d5b
27 changed files with 0 additions and 0 deletions

51
examples/crypto/md5_demo.fun Executable file
View file

@ -0,0 +1,51 @@
#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://fun-lang.xyz/
*
* Copyright 2025 Johannes Findeisen <you@hanez.org>
* Licensed under the terms of the Apache-2.0 license.
* https://opensource.org/license/apache-2-0
*
* Added: 2025-09-29
*/
// Include the pure Fun MD5 library
include <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
// "Have Fun!"
print(md5.md5_str("Have Fun!")) // -> 812f2c01287af0e7c0a0b3daa381a51a
// More MD5
print(md5.md5_str("a")) // -> 0cc175b9c0f1b6a831c399e269772661
print("=== Done ===")
/* Expected output:
=== MD5 demo (hex input) ===
900150983cd24fb0d6963f7d28e17f72
d41d8cd98f00b204e9800998ecf8427e
f96b697d7cb7938d525a2f31aaf161d0
c3fcd3d76192e4007dfb496cca67e13b
812f2c01287af0e7c0a0b3daa381a51a
0cc175b9c0f1b6a831c399e269772661
=== Done ===
*/