diff --git a/src/database/crypt.jmc b/src/database/crypt.jmc index b5dd9be..66283e7 100644 --- a/src/database/crypt.jmc +++ b/src/database/crypt.jmc @@ -1,3 +1,16 @@ +@lazy +function test_hashInteger($test_val) { + $integerToHash = $test_val; + + database.crypt.hashInteger(); + + tellraw @a $hashedInteger.toString(); + + database.crypt.clean(); + + tellraw @a $hashedInteger.toString(); +} + class database.crypt { function hashString() {} @@ -6,12 +19,19 @@ class database.crypt { $cryptConstant = 7; $cryptPrime = 15331; - $$input = $(integer); - $hash = $input; - $hash *= $cryptMultiplyer; - $hash += $cryptConstant; - $hash %= $cryptPrime; + # + # $integerToHash must already be initialized + # + $hashedInteger = $integerToHash; + $hashedInteger *= $cryptMultiplyer; + $hashedInteger += $cryptConstant; + $hashedInteger %= $cryptPrime; - tellraw @a $hash.toString(); + # run database.crypt.clean() after hased value is used + } + + function clean() { + scoreboard players reset $integerToHash __variable__; + scoreboard players reset $hashInteger __variable__; } }