コード例 #1
0
def job(digest_portion):
    start_time = time.time()
    loop_time = int(start_time)
    loop_digest = totp.generate_digest(loop_time, const[sys.argv[1]], digest_portion)
    print(f'     Time:  {start_time}')
    print(f'Loop time:  {loop_time}')
    print(f'   Digest:  {loop_digest}\n')
    unicorn.clear()
    fill_board(loop_digest, digest_portion)
コード例 #2
0
def job(digest_portion):
    start_time = time.time()
    loop_time = int(start_time)
    loop_digest = totp.generate_digest(loop_time, const[sys.argv[1]], digest_portion)
    print(f'  Time is:  {start_time}')
    print(f'Loop time:  {loop_time}')
    print(f'   Digest:  {loop_digest}')
    fill_board(loop_digest, digest_portion)
    ms_of_loop = 1000 * (time.time() - start_time)
    print(f'       ms:  {str(ms_of_loop)}\n')
コード例 #3
0
def test_generate_digest_returns_portion_of_digest():
    totp_time = [9000, 8675309]
    totp_secret = ["it's over", "Tommy Tutone"]
    totp_portion = [4, 8]

    expected = ["748a", "bb755c15"]

    for i in range(len(expected)):
        actual = totp.generate_digest(totp_time[i], totp_secret[i],
                                      totp_portion[i])
        assert expected[i] == actual
コード例 #4
0
def test_generate_digest_returns_the_full_hash():
    totp_time = [1, 42]
    totp_secret = ["", "shh!"]

    expected = [
        "e0bc614e4fd035a488619799853b075143deea596c477b8dc077e309c0fe42e9",
        "de0c1b8257e09233913795a926ef2e29831fb2f851afbed56c47bdddc15b0e16"
    ]

    for i in range(len(expected)):
        actual = totp.generate_digest(totp_time[i], totp_secret[i])
        assert expected[i] == actual
コード例 #5
0
ファイル: signalmaker.py プロジェクト: jduffey/watchgirl
def job(digest_portion):
    start_time = time.time()
    loop_time = int(start_time)
    print(f'  Time is:  {start_time}')
    print(f'Loop time:  {loop_time}\n')

    loop_digest = totp.generate_digest(loop_time, const['SECRET_01'],
                                       digest_portion)

    digest_char_counter = 0

    outer_list = []
    for which_row in range(0, const['NUM_ROWS']):

        inner_list = []
        for which_column in range(0, const['NUM_COLS']):

            digit_to_use_for_color = loop_digest[digest_char_counter]
            digest_char_counter += 1

            draw_color_icon(which_column, which_row, digit_to_use_for_color)

            inner_list.append(digit_to_use_for_color)

        outer_list.append(inner_list)

    draw_horizontal_borders()
    draw_vertical_borders()
    update_display()

    microseconds_of_loop = 1000 * 1000 * (time.time() - start_time)

    print('   micro s: ' + str(microseconds_of_loop))
    digest_portion = const['NUM_COLS'] * const['NUM_ROWS']
    print('      TOTP: ' +
          totp.generate_digest(loop_time, const['SECRET_01'], digest_portion))
    [print(x) for x in outer_list]
コード例 #6
0
def job(digest_portion):
    start_time = time.time()
    loop_time = int(start_time)
    print(f'  Time is:  {start_time}')
    print(f'Loop time:  {loop_time}\n')

    loop_digest_01 = totp.generate_digest(loop_time, const['SECRET_01'],
                                          digest_portion)
    loop_digest_02 = totp.generate_digest(loop_time, const['SECRET_02'],
                                          digest_portion)
    loop_digest_03 = totp.generate_digest(loop_time, const['SECRET_03'],
                                          digest_portion)
    loop_digests = [loop_digest_01, loop_digest_02, loop_digest_03]

    signal_placement = 0
    for loop_digest in loop_digests:

        digest_char_counter = 0
        for which_row in range(0, const['NUM_ROWS']):
            for which_column in range(0, const['NUM_COLS']):
                digit_to_use_for_color = loop_digest[digest_char_counter]
                digest_char_counter += 1
                draw_color_icon(which_column + signal_placement, which_row,
                                digit_to_use_for_color)
        signal_placement += 2

    draw_horizontal_borders()
    draw_vertical_borders()
    update_display()

    microseconds_of_loop = 1000 * 1000 * (time.time() - start_time)

    print('   micro s: ' + str(microseconds_of_loop))
    digest_portion = const['NUM_COLS'] * const['NUM_ROWS']
    print('      TOTP: ' +
          totp.generate_digest(loop_time, const['SECRET_03'], digest_portion))
コード例 #7
0
while is_unicorn_active:

    loop_counter += 1

    if loop_counter > 1:
        loop_start_time = int(time.time())
    else:
        loop_start_time = app_start_time - (app_start_time %
                                            const['PERIOD_IN_SECONDS'])
        sleep_between_loops()
        continue

    print(f'\nLoop start: {loop_start_time}')

    loop_digest = totp.generate_digest(loop_start_time, const['SECRET_01'],
                                       digest_portion)

    digest_char_counter = 0

    outer_list = []
    for which_row in range(0, const['NUM_ROWS']):

        inner_list = []
        for which_column in range(0, const['NUM_COLS']):

            digit_to_use_for_color = loop_digest[digest_char_counter]
            digest_char_counter += 1

            #draw_color_icon(which_column, which_row, digit_to_use_for_color)

            inner_list.append(digit_to_use_for_color)
コード例 #8
0
ファイル: app.py プロジェクト: jduffey/stills
number_color_dict = {
    0: 'RED',
    1: 'GREEN',
    2: 'BLUE',
    3: 'WHITE',
}


secret = 'bbb'

synchronize_time()

take_photos()

filenames = generate_filename_msgs()

expected_colors = {}

avg_time_for_picamera_to_take_pic = 6

for filename in filenames:
    time_msg = round_down(filename + avg_time_for_picamera_to_take_pic, 5)
    expected_colors[f'{filename}.jpg'] = \
    (get_color(generate_digest(time_msg, secret, 1)), time_msg)

print(f'\nExpected colors - {len(expected_colors)} image(s):')
for k, v in expected_colors.items():
    print(f'{k} : {v}')


#os.system('sudo shutdown now')