diff --git a/CMakeLists.txt b/CMakeLists.txt index 247d09f..7287827 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.10) -project(fun VERSION 0.38.9 LANGUAGES C) +project(fun VERSION 0.38.10 LANGUAGES C) set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD_REQUIRED ON) diff --git a/lib/crypt/aes256.fun b/lib/crypt/aes256.fun index 3afd93e..9b0eaca 100644 --- a/lib/crypt/aes256.fun +++ b/lib/crypt/aes256.fun @@ -36,14 +36,6 @@ class AES256() i = i + 2 return arr - fun bytes_to_hex(this, arr) - i = 0 - out = [] - while i < len(arr) - push(out, two_hex(arr[i])) - i = i + 1 - return join(out, "") - // ---------- Finite field helpers (GF(2^8)) ---------- fun b8(this, x) // clamp to 0..255 @@ -245,7 +237,7 @@ class AES256() pt = this.from_hex(pt_hex32) key = this.from_hex(key_hex64) ct = this.encrypt_block_bytes(pt, key) - return this.bytes_to_hex(ct) + return bytes_to_hex(ct) fun encrypt_ecb_hex(this, hexStr, key_hex64) // Robust handling that avoids substr semantics ambiguity by working on bytes @@ -276,4 +268,4 @@ class AES256() push(out_bytes, ct_blk[k]) k = k + 1 off = off + 16 - return this.bytes_to_hex(out_bytes) + return bytes_to_hex(out_bytes) diff --git a/lib/crypt/crc32.fun b/lib/crypt/crc32.fun index 81cb7d2..f9ff6cc 100644 --- a/lib/crypt/crc32.fun +++ b/lib/crypt/crc32.fun @@ -59,21 +59,13 @@ class CRC32() i = i + 2 return arr - fun bytes_to_hex(this, arr) - i = 0 - out = [] - while i < len(arr) - push(out, two_hex(arr[i])) - i = i + 1 - return join(out, "") - fun u32_to_hex8(this, n) // big-endian printing (MSB first), common for CRC displays b3 = this.and32(this.shr32(n, 24), 255) b2 = this.and32(this.shr32(n, 16), 255) b1 = this.and32(this.shr32(n, 8), 255) b0 = this.and32(n, 255) - return this.bytes_to_hex([b3, b2, b1, b0]) + return bytes_to_hex([b3, b2, b1, b0]) // Bitwise update (no table needed) using reflected polynomial 0xEDB88320 POLY = 3988292384 // 0xEDB88320 diff --git a/lib/crypt/md5.fun b/lib/crypt/md5.fun index 36ae7bd..c8ff709 100644 --- a/lib/crypt/md5.fun +++ b/lib/crypt/md5.fun @@ -90,14 +90,6 @@ class MD5() i = i + 2 return arr - fun bytes_to_hex(this, arr) - i = 0 - out = [] - while i < len(arr) - push(out, two_hex(arr[i])) - i = i + 1 - return join(out, "") - // MD5 aux fun F(this, x, y, z) return this.or32(this.and32(x, y), this.and32(this.not32(x), z)) @@ -213,9 +205,9 @@ class MD5() fun md5_hex(this, hexStr) bytes = this.from_hex(hexStr) digest = this.md5_bytes(bytes) - return this.bytes_to_hex(digest) + return bytes_to_hex(digest) fun md5_str(this, str) bytes = string_to_bytes_ascii(str) digest = this.md5_bytes(bytes) - return this.bytes_to_hex(digest) + return bytes_to_hex(digest) diff --git a/lib/crypt/sha1.fun b/lib/crypt/sha1.fun index 6611f1c..e2ad3d4 100644 --- a/lib/crypt/sha1.fun +++ b/lib/crypt/sha1.fun @@ -53,14 +53,6 @@ class SHA1() i = i + 2 return arr - fun bytes_to_hex(this, arr) - i = 0 - out = [] - while i < len(arr) - push(out, two_hex(arr[i])) - i = i + 1 - return join(out, "") - // padding (SHA-1): append 0x80, then zeros until length ≡ 56 (mod 64), then 64-bit length big-endian fun pad_bytes(this, bytes) L = len(bytes) @@ -164,9 +156,9 @@ class SHA1() fun sha1_hex(this, hexStr) bytes = this.from_hex(hexStr) digest = this.sha1_bytes(bytes) - return this.bytes_to_hex(digest) + return bytes_to_hex(digest) fun sha1_str(this, str) bytes = string_to_bytes_ascii(str) digest = this.sha1_bytes(bytes) - return this.bytes_to_hex(digest) + return bytes_to_hex(digest) diff --git a/lib/crypt/sha256.fun b/lib/crypt/sha256.fun index 6d6c113..92d6432 100644 --- a/lib/crypt/sha256.fun +++ b/lib/crypt/sha256.fun @@ -102,14 +102,6 @@ class SHA256() i = i + 2 return arr - fun bytes_to_hex(this, arr) - i = 0 - out = [] - while i < len(arr) - push(out, two_hex(arr[i])) - i = i + 1 - return join(out, "") - // padding (SHA-256) fun pad_bytes(this, bytes) L = len(bytes) @@ -217,10 +209,10 @@ class SHA256() fun sha256_hex(this, hexStr) bytes = this.from_hex(hexStr) digest = this.sha256_bytes(bytes) - return this.bytes_to_hex(digest) + return bytes_to_hex(digest) // Hash raw string bytes (printable ASCII). Example: sha256_str("616263") -> ee2109... fun sha256_str(this, str) bytes = string_to_bytes_ascii(str) digest = this.sha256_bytes(bytes) - return this.bytes_to_hex(digest) + return bytes_to_hex(digest) diff --git a/lib/crypt/sha512.fun b/lib/crypt/sha512.fun index b9b2095..e66aa0f 100644 --- a/lib/crypt/sha512.fun +++ b/lib/crypt/sha512.fun @@ -45,15 +45,6 @@ class SHA512() i = i + 2 return arr - fun bytes_to_hex(this, arr) - out = [] - number i = 0 - number L = len(arr) - while i < L - push(out, two_hex(arr[i])) - i = i + 1 - return join(out, "") - // -------- 32/64 helpers -------- fun u32(this, x) m = 4294967296 @@ -316,10 +307,10 @@ class SHA512() fun sha512_hex(this, hexStr) bytes = this.from_hex(hexStr) digest = this.sha512_bytes(bytes) - return this.bytes_to_hex(digest) + return bytes_to_hex(digest) // Hash raw string bytes (printable ASCII). Example: sha512_str("616263") -> ee2109... fun sha512_str(this, str) bytes = string_to_bytes_ascii(str) digest = this.sha512_bytes(bytes) - return this.bytes_to_hex(digest) + return bytes_to_hex(digest)