Tweak hash function and add test
All checks were successful
Deploy datapack to dev / Build (push) Successful in 7s
All checks were successful
Deploy datapack to dev / Build (push) Successful in 7s
This commit is contained in:
parent
7be40debe7
commit
8d3ef2b799
@ -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__;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user