File path refactoring. No code changes. (0.37.51)
This commit is contained in:
parent
2fa8f8653e
commit
db68b30d5b
27 changed files with 0 additions and 0 deletions
54
examples/crypto/crc32_example.fun
Executable file
54
examples/crypto/crc32_example.fun
Executable file
|
|
@ -0,0 +1,54 @@
|
|||
#!/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-11-26
|
||||
*/
|
||||
|
||||
// Example: Using the CRC32 class from lib/crypt/crc32.fun
|
||||
|
||||
include <crypt/crc32.fun>
|
||||
|
||||
print("-- CRC32 example --")
|
||||
|
||||
c = CRC32()
|
||||
|
||||
// 1) Known test vector: "123456789" -> cbf43926
|
||||
msg = "123456789"
|
||||
crc1 = c.crc32_str(msg)
|
||||
print("Input (ASCII): " + msg)
|
||||
print("CRC32: " + crc1) // expected: cbf43926
|
||||
|
||||
print("")
|
||||
|
||||
// 2) Same data provided as hex string
|
||||
hex_msg = "313233343536373839" // hex for "123456789"
|
||||
crc2 = c.crc32_hex(hex_msg)
|
||||
print("Input (hex): " + hex_msg)
|
||||
print("CRC32: " + crc2) // expected: cbf43926
|
||||
|
||||
print("")
|
||||
|
||||
// 3) Another quick demo
|
||||
other = "Fun language"
|
||||
crc3 = c.crc32_str(other)
|
||||
print("Input (ASCII): " + other)
|
||||
print("CRC32: " + crc3)
|
||||
|
||||
/* Expected output:
|
||||
-- CRC32 example --
|
||||
Input (ASCII): 123456789
|
||||
CRC32: cbf43926
|
||||
|
||||
Input (hex): 313233343536373839
|
||||
CRC32: cbf43926
|
||||
|
||||
Input (ASCII): Fun language
|
||||
CRC32: d7d83272
|
||||
*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue