Beispiel #1
0
parser.add_option("-i", "--id",          action="store", type="int",     dest="id",       help="Set id (integer)",                    default=0)

(options, args) = parser.parse_args()

company  = options.company
owner    = options.owner
desc     = options.desc
seed     = options.password
lock     = options.lock
id       = options.id

def ok(string, bool):
  print string+"... ",
  if bool:
    print "ok"
  else:
    print "fail"
    exit(1)

ok("set_owner",     picosafelogin.set_owner(owner))
ok("set_desc",      picosafelogin.set_description(desc))
ok("set_id",        picosafelogin.set_id(id))
ok("set_company",   picosafelogin.set_company(company))
ok("set_seed",      picosafelogin.set_seed(seed))
ok("set_timestamp", picosafelogin.set_timestamp(int(time()), seed))
#print
#print seed

if lock:
    ok("set_lock", picosafelogin.set_lock())
Beispiel #2
0
from __future__ import division
import picosafelogin
from optparse import OptionParser
from sys import exit
from random import random
from time import sleep

parser = OptionParser()
parser.add_option("-n", "--tries", action="store", type="int",    dest="tries", help="number of tries", default=1000)
parser.add_option("-s", "--seed",  action="store", type="string", dest="seed",  help="Set password (exactly 42 chars)",     default="")

(options, args) = parser.parse_args()

tries = options.tries
seed  = options.seed

y2010 = 1293840000
y2030 = 1893456000

for i in xrange(tries):
  timestamp_1 = y2010+int(random()*(y2030-y2010))
  picosafelogin.set_timestamp(timestamp_1, seed)
  timestamp_2 = picosafelogin.get_time()

  if timestamp_1 != timestamp_2:
    print "%d != %d (diff: %d)" % (timestamp_1, timestamp_2, timestamp_1-timestamp_2)
  
  if (i % 10) == 0:
    print "% 2.2f%%" % (i/tries*100)