Exemple #1
0
from arduino import Arduino
from stattests import StatTests
import sys

if len(sys.argv) != 2:
    print "usage: python analyze.py <file>"
    sys.exit()

st = StatTests(open(sys.argv[1]).read())
st.monobit()
Exemple #2
0
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()

Exemple #3
0
#coding: utf-8
"""Just a short program that grabs a bitstring s and writes to a file or whatever"""

from arduino import Arduino
from stattests import StatTests
from sys import stdin, argv

ard = Arduino()
# FIPS 140-1 demands a bitstring s of length 20 000. 
# l = 20000
l = 1000

s = ''.join([a for a in ard.meanrand(l)])
st = StatTests(s)
print st.monobit()

# File stuff
# fname = argv[1] if len(argv) > 1 else 's.txt'
# f = open(fname, 'w')
# s = ''.join([a for a in ard.meanrand(l)])
# f.write(s)
# f.close()


Exemple #4
0
#coding: utf-8
"""Just a short program that grabs a bitstring s and writes to a file or whatever"""

from arduino import Arduino
from stattests import StatTests
from sys import stdin, argv

ard = Arduino()
# FIPS 140-1 demands a bitstring s of length 20 000.
# l = 20000
l = 1000

s = ''.join([a for a in ard.meanrand(l)])
st = StatTests(s)
print st.monobit()

# File stuff
# fname = argv[1] if len(argv) > 1 else 's.txt'
# f = open(fname, 'w')
# s = ''.join([a for a in ard.meanrand(l)])
# f.write(s)
# f.close()