From 6d2bfa3d81b9817b20eb349da2972828ac869f61 Mon Sep 17 00:00:00 2001 From: lifeadventurer Date: Tue, 21 Nov 2023 11:48:09 +0800 Subject: [PATCH] fix: hash bug --- fortune_generator/fortune.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fortune_generator/fortune.js b/fortune_generator/fortune.js index 015e3bf..62af163 100644 --- a/fortune_generator/fortune.js +++ b/fortune_generator/fortune.js @@ -151,8 +151,8 @@ function Appear() { // TODO: improve the hash process let hashDate = Math.round(Math.log10(year * ((month << (Math.log10(num[3]) + 1)) * (date << Math.log10(num[2]))))); - let seed1 = (num[0] >> hashDate) * (num[1] >> Math.min(hashDate, 2)) + (num[2] << 1) * (num[3] >> 3) + (date << 3) * (month << hashDate) + year; - let seed2 = (num[0] << (hashDate + 2)) * (num[1] << hashDate) + (num[2] << 1) * (num[3] << 3) + (date << (hashDate - 1)) * (month << 4) + year >> hashDate; + let seed1 = (num[0] >> hashDate) * (num[1] >> Math.min(hashDate, 2)) + (num[2] << 1) * (num[3] >> 3) + (date << 3) * (month << hashDate) + (year * day) >> 2; + let seed2 = (num[0] << (hashDate + 2)) * (num[1] << hashDate) + (num[2] << 1) * (num[3] << 3) + (date << (hashDate - 1)) * (month << 4) + year >> hashDate + (date * day) >> 1; // decide the status let status_index = ((seed1 + seed2) % statusLen + statusLen) % statusLen;