Xoroshiro128+ Solver
[Random Home][Home]
Xoroshiro128+ is one of the fastest Pseudorandom number generators (PRNGs). It was created in 2016 by David Blackman and Sebastiano Vigna and requires two 64-bit unsigned integers as seeds. In this case we will discover the seeds for an eight character input. The page will calculate the two seed values that can generate a word within the random number.
|
Outline
Code
The following shows a C++ version of the code:
import sys class Xoroshiro128Plus(object): def __init__(self, seed): self.seed = seed @staticmethod def rotl(x, k): return ((x << k) & 0xffffffffffffffff) | (x >> 64 - k) def next(self): s0 = self.seed[0] s1 = self.seed[1] result = (s0 + s1) & 0xffffffffffffffff s1 ^= s0 self.seed[0] = self.rotl(s0, 55) ^ s1 ^ ((s1 << 14) & 0xffffffffffffffff) self.seed[1] = self.rotl(s1, 36) return result word1="Tuesday" word2="24 Aug21" if (len(sys.argv)>1): word1=str(sys.argv[1]) word1=word1.ljust(8) word1=word1.encode() word2=word2.ljust(8) word2=word2.encode() val1=int.from_bytes(word1,byteorder='little') val2=int.from_bytes(word2,byteorder='little') print("Word:\t",word1.decode()) print() print(" Hex: ",val1) # print("Word 2: ",val2) seed1,seed2=find_seed([(0x0, 0x0), (val1, 0xffffffffffffffff)] ) print("\nXoroshiro128+ seeds: ",seed1,seed2) print ("\nGenerated:") generator = Xoroshiro128Plus([seed1, seed2]) for i in range(10): val=generator.next() print (i,hex(val),'\t',end =" ") print(repr(bin2chr(val)))
A sample run:
Word: england Hex: 2334111871594360421 Xoroshiro128+ seeds: 5152964752980186246 11387002426937885074 Generated: 0 0xe589c48483a2d618 '\x18Ö¢\x83\x84Ä\x89å' 1 0x20646e616c676e65 'england ' 2 0x8ef6a630fcff1d0 'ÐñÏ\x0fcjï\x08' 3 0xe178c781d769112b '+\x11i×\x81Çxá' 4 0x863e604c59cbd67f '\x7fÖËYL`>\x86' 5 0x3bd587d6b0b6486d 'mH¶°Ö\x87Õ;' 6 0x8a234049bc1d0be7 'ç\x0b\x1d¼I@#\x8a' 7 0xc2bbf1961b929b6e 'n\x9b\x92\x1b\x96ñ»Â' 8 0x903fb6a76b16fd69 'iý\x16k§¶?\x90' 9 0xdce7ab46e1967bf2 'ò{\x96áF«çÜ'