commit ad1d321637d963112799df8d7add5b70c222371d parent c85b8ec790b77ce7c6ddbbab0849e00ec707b10c Author: mpizzzle <michael.770211@gmail.com> Date: Sat, 16 Feb 2019 17:43:51 +0000 simplifying untemper 11 function Diffstat:
| M | set3/clone_mt_rng_state.py | | | 13 | +++++-------- |
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/set3/clone_mt_rng_state.py b/set3/clone_mt_rng_state.py @@ -44,15 +44,12 @@ class MT19937: self.mt[i] = self.mt[i] ^ 0x9908b0df self.index = 0 -#todo: rewrite this function now you have a better grasp on it. def untemper_11(yy): - y = _int32(yy) - temp1 = y >> (32 - 11) - temp2 = (y & 0x1fffff) >> (32 - 11 - 11) - temp3 = temp1 ^ temp2 - temp4 = int(str(format(temp1, '#011b')) + str(format(temp3, '011b')), 2) >> 1 - temp5 = temp4 ^ y - return _int32(temp5) + y = yy ^ ((yy & 0xffe00000) >> 11) + y = yy ^ ((y & 0xfffffc00) >> 11) + y = yy ^ ((y & 0xffffffff) >> 11) + + return _int32(y) def untemper_7(yy): y = yy ^ (((yy & 0x7f) << 7) & 2636928640)