Added some crypto 100% implemented in Fun. (0.11.0)
This commit is contained in:
parent
5d3cfd9f65
commit
12a5646d56
25 changed files with 1926 additions and 12 deletions
34
examples/md5_demo.fun
Normal file
34
examples/md5_demo.fun
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#!/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 ===")
|
||||
Loading…
Add table
Add a link
Reference in a new issue