From 584ac9f00e94cbcf45dfbfd82801aae0d63dcfc5 Mon Sep 17 00:00:00 2001 From: wum0 <12880918+wum0@users.noreply.github.com> Date: Sun, 4 May 2025 01:46:43 +0800 Subject: [PATCH] Create brc4_1_4_5.py --- algorithms/brc4_1_4_5.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 algorithms/brc4_1_4_5.py diff --git a/algorithms/brc4_1_4_5.py b/algorithms/brc4_1_4_5.py new file mode 100644 index 0000000..6dfb8c3 --- /dev/null +++ b/algorithms/brc4_1_4_5.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +DESCRIPTION = "Hash algorithm used in BRC4 1.4.5" +# Type can be either 'unsigned_int' (32bit) or 'unsigned_long' (64bit) +TYPE = 'unsigned_int' +# Test must match the exact hash of the string 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' +TEST_1 = 3471553803 + + +def hash(data): + result = 0 + for c in data: + temp = 2049 * result + temp |= 0x2800000 + temp += c + result = temp & 0xFFFFFFFF + + return result