diceware-generator/dwg.py
2021-10-02 15:40:52 +08:00

28 lines
594 B
Python

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