コード例 #1
0
ファイル: get20k.py プロジェクト: benediktkr/ardrand
elif algorithm == 'updownrand':
    s = ''.join(ard.updownrand(k))
elif algorithm == 'mix':
    s = ''.join(ard.mixmeanupdown(k))
elif algorithm == 'leastsig':
    s = ''.join(ard.leastsigrand(k))
elif algorithm == 'twol':
    s = ''.join(ard.twoleastsignrand(k))

elif algorithm == 'vanilla':
    s = ''.join(ard.vanilla(k))

if "-p" in sys.argv:
    print s


st = StatTests(s)
print st.monobit()
print st.poker()
print st.runs()
fips = FipsTests(s)
print fips.monobit()
print fips.poker()
print fips.runs()
save = (sys.argv[3] if len(sys.argv) >= 4 else "") or raw_input("Save to: ")
if save:
    f = open(save, 'w')
    f.write(s)
    f.close()

コード例 #2
0
ファイル: all.py プロジェクト: benediktkr/ardrand
for alg in algs:
    print "[ ]", alg.__doc__.split('\n')[0]
    means = [[]]*3
    for i in range(3):
        print "  [+] Run", i, ":"
        # Generate the bitstring
        start = time()
        b = ''.join(alg(k))
        end = time()
        print "    [ ] Bitrate:", k/(end-start), "bits/second"
        print "    [ ] Time:", end-start, "seconds"
        fips = FipsTests(b)

        mono, X1, n1 = fips.monobit()
        poker, X3 = fips.poker()
        runs, X4, G, B = fips.runs()
        longruns = fips.longruns()

        means[i] = [X1, X3, X4, k/(end-start)]
        
        #Xmeanl.append((X1, X3, X4))
        print "    [ ] Monobit test"
        print "        [+] Passed" if mono else "        [!] Failed"
        print "        [ ] X1 =", X1, "n1 =", n1
        
        print "    [ ] Poker test"
        print "        [+] Passed" if poker else "        [!] Failed"
        print "        [ ] X3 =", X3

        print "    [ ] Runs test"
コード例 #3
0
ファイル: all.py プロジェクト: benediktkr/ardrand
for alg in algs:
    print "[ ]", alg.__doc__.split('\n')[0]
    means = [[]] * 3
    for i in range(3):
        print "  [+] Run", i, ":"
        # Generate the bitstring
        start = time()
        b = ''.join(alg(k))
        end = time()
        print "    [ ] Bitrate:", k / (end - start), "bits/second"
        print "    [ ] Time:", end - start, "seconds"
        fips = FipsTests(b)

        mono, X1, n1 = fips.monobit()
        poker, X3 = fips.poker()
        runs, X4, G, B = fips.runs()
        longruns = fips.longruns()

        means[i] = [X1, X3, X4, k / (end - start)]

        #Xmeanl.append((X1, X3, X4))
        print "    [ ] Monobit test"
        print "        [+] Passed" if mono else "        [!] Failed"
        print "        [ ] X1 =", X1, "n1 =", n1

        print "    [ ] Poker test"
        print "        [+] Passed" if poker else "        [!] Failed"
        print "        [ ] X3 =", X3

        print "    [ ] Runs test"