smp-datapack/src/database/crypt.jmc
themodrnhakr b309485d18
All checks were successful
Deploy datapack to dev / Build (push) Successful in 6s
Add test function to actually run the tests
2025-03-21 20:23:56 -05:00

42 lines
818 B
Plaintext

@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() {}
function hashInteger() {
$cryptMultiplyer = 49;
$cryptConstant = 7;
$cryptPrime = 15331;
#
# $integerToHash must already be initialized
#
$hashedInteger = $integerToHash;
$hashedInteger *= $cryptMultiplyer;
$hashedInteger += $cryptConstant;
$hashedInteger %= $cryptPrime;
# run database.crypt.clean() after hased value is used
}
function clean() {
scoreboard players reset $integerToHash __variable__;
scoreboard players reset $hashInteger __variable__;
}
function test() {
test_hashInteger(1748586758492046);
}
}