Example #1
0
    def test_different_srand(self):
        php_rand.mt_srand(12345)
        a = [php_rand.mt_rand() for i in xrange(10)]

        php_rand.mt_srand(12346)
        b = [php_rand.mt_rand() for i in xrange(10)]

        self.assertNotEqual(a, b)
Example #2
0
    def test_same_srand(self):
        php_rand.mt_srand(12345)
        a = [php_rand.mt_rand() for i in xrange(10)]

        php_rand.mt_srand(12345)
        b = [php_rand.mt_rand() for i in xrange(10)]

        self.assertEqual(a, b)
Example #3
0
    def test_different_srand(self):
        php_rand.mt_srand(12345)
        a = [php_rand.mt_rand() for i in xrange(10)]

        php_rand.mt_srand(12346)
        b = [php_rand.mt_rand() for i in xrange(10)]

        self.assertNotEqual(a, b)
Example #4
0
    def test_same_srand(self):
        php_rand.mt_srand(12345)
        a = [php_rand.mt_rand() for i in xrange(10)]

        php_rand.mt_srand(12345)
        b = [php_rand.mt_rand() for i in xrange(10)]

        self.assertEqual(a, b)
Example #5
0
    def test_with_php(self):
        php_result = [1863022934, 1105767797, 2076010745, 1928709656,
                      559367964, 622044451, 1926800759, 1672524053,
                      1332912347, 2000644112]

        php_rand.mt_srand(123456)
        my_result = [php_rand.mt_rand() for i in xrange(10)]

        self.assertEqual(php_result, my_result)
Example #6
0
def obtener_semilla_dn_fix(semilla):
    chars = '0123456789'
    ii = semilla
    php_rand.mt_srand((0xFFFFFFFF & (ii)))
    ret = ''
    for j in range(10):
        g = php_rand.mt_rand(0, len(chars) - 1)
        ret = ret + chars[g]
    return ret
Example #7
0
    def test_with_php(self):
        php_result = [
            1863022934, 1105767797, 2076010745, 1928709656, 559367964,
            622044451, 1926800759, 1672524053, 1332912347, 2000644112
        ]

        php_rand.mt_srand(123456)
        my_result = [php_rand.mt_rand() for i in xrange(10)]

        self.assertEqual(php_result, my_result)
Example #8
0
def obtener_semilla_dn(dn_qlink, semilla):
    chars = '0123456789'
    ii = semilla
    # aproximaciones...
    len_prueba = 2 * 99999  # probar a lo sumo dos segundos hacia adelante (parte en microsegundos que se agrega)
    max = 0
    for i in xrange(len_prueba):
        php_rand.mt_srand((0xFFFFFFFF & (ii + i)))
        for j in range(len(dn_qlink)):
            g = php_rand.mt_rand(0, len(chars) - 1)
            if chars[g] != dn_qlink[j]:
                break
            if (j + 1 > max):
                max = j + 1
                if max == 10:
                    return ii + i
        if (i % 100000 == 0):
            print ".",
            sys.stdout.flush()
Example #9
0
def obtener_semilla(parcial_qlink):
    chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
    epoch = int(time.time())
    # aproximaciones...
    len_prueba = 60 * 60 * 24 * 1000 * 2  # probar a lo sumo dos días hacia atrás desde máximo posible
    ii = 99999 + 999 + epoch * 1001
    max = 0
    for i in xrange(len_prueba):
        php_rand.mt_srand((0xFFFFFFFF & (ii - i)))
        for j in range(len(parcial_qlink)):
            g = php_rand.mt_rand(0, len(chars) - 1)
            if chars[g] != parcial_qlink[j]:
                break
            if (j + 1 > max):
                max = j + 1
                if max == 10:
                    return ii - i
        if (i % 100000 == 0):
            print ".",
            sys.stdout.flush()
Example #10
0
#coding: utf8

__author__ = 'gifts'

import php_rand

for i in xrange(10000000):
    php_rand.mt_srand(i)
    php_rand.mt_rand()

print php_rand.mt_rand()
Example #11
0
# resp_header_dt = datetime.datetime.strptime('Mon, 01 May 2017 17:36:28 GMT', '%a, %d %b %Y %H:%M:%S GMT')
# resp_header_ue = time.mktime(resp_header_dt.timetuple())
# resp_header_ue = int(resp_header_ue)

# js_ue = 1493591895676

# ii = resp_header_ue + js_ue
tt = int(time.time())
ii = tt * 1001
ll = 60 * 60 * 24 * 1000

max = 0
for i in xrange(ll):
    #mt = php_mt_srand(i+ii)
    #php_rand.mt_srand((0xFFFFFFFF & i))
    php_rand.mt_srand((0xFFFFFFFF & (ii - i)))
    for j in range(len(xxx)):
        #xx = php_mt_rand(mt, 0, len(chars)-1, PHP_MT_RAND_MAX)
        xx = php_rand.mt_rand(0, len(chars) - 1)
        if chars[xx] != xxx[j]:
            break
        if (j + 1 > max):
            max = j + 1
            if max == 10:
                raise Exception("encontrado! valor: " + str(ii - i) +
                                " - estimado: " + str((ii - i) / 1001))
    if (i % 100000 == 0):
        print "i: " + str(i) + "/" + str(ll) + " - max: " + str(max)
        sys.stdout.flush()
Example #12
0
# if chars[xx] != xxx[j]:
# break
# if (j + 1 > max):
# max = j + 1
# if max == 10:
# raise Exception("encontrado! valor: " + str(ii-i) + " - estimado: " + str((ii-i)/1001))
# if (i % 100000 == 0):
# print "i: " + str(i) + "/" + str(ll) + " - max: " + str(max)
# sys.stdout.flush()

ii = 1495629601467
print ii
print hex(ii)
print(0x7FFFFFFF & ii)
print hex(0x7FFFFFFF & ii)
php_rand.mt_srand(0x7FFFFFFF & ii)
xx = php_rand.mt_rand(0, 10000000)
print xx
print hex(xx)

print
print

aa = ii + ll
ii = (0x7FFFFFFF & ii)
aa = (0x7FFFFFFF & aa)
print ii
print aa
print aa - ii
print