diceware-generator/dwg.py

28 lines
594 B
Python
Raw Normal View History

2021-10-02 15:40:52 +08:00
import random
2021-09-16 20:33:56 +08:00
import sys
import pandas as pd
DW = pd.read_csv('pinyin.wordlist')
SEPARATOR = [
2021-10-02 15:40:52 +08:00
'!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/',
':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_', '`', '{', '|',
'}', '~'
2021-09-16 20:33:56 +08:00
]
LENGTH = int(sys.argv[1]) if len(sys.argv) > 1 else 6
CHT = []
WORD = []
for i in range(LENGTH):
2021-10-02 15:40:52 +08:00
ID = random.SystemRandom().randint(0, 8191)
CHT.append(DW['cht'].values[ID])
WORD.append(DW['word'].values[ID])
ID = random.SystemRandom().randint(0, 31)
2021-09-16 20:33:56 +08:00
print(' '.join(CHT))
print(SEPARATOR[ID].join(WORD))