Remove random.org version
This commit is contained in:
parent
7be9cee9cd
commit
852477aa6e
@ -13,10 +13,6 @@ $ poetry install
|
|||||||
|
|
||||||
```
|
```
|
||||||
$ poetry shell
|
$ poetry shell
|
||||||
# Use random.org
|
|
||||||
$ python dwg.py # by default, it will generate 6-word password
|
$ python dwg.py # by default, it will generate 6-word password
|
||||||
$ python dwg.py 7 # generate 7-word password
|
$ python dwg.py 7 # generate 7-word password
|
||||||
# Use urandom
|
|
||||||
$ python dwg8k.py # by default, it will generate 6-word password
|
|
||||||
$ python dwg8k.py 7 # generate 7-word password
|
|
||||||
```
|
```
|
||||||
|
52
dwg.py
52
dwg.py
@ -1,63 +1,27 @@
|
|||||||
import json
|
import random
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import requests
|
|
||||||
|
|
||||||
DW = pd.read_csv('pinyin.wordlist')
|
DW = pd.read_csv('pinyin.wordlist')
|
||||||
|
|
||||||
SEPARATOR = [
|
SEPARATOR = [
|
||||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '!', '"', '#', '$', '%',
|
'!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/',
|
||||||
'&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>',
|
':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_', '`', '{', '|',
|
||||||
'?', '@', '[', '\\', ']', '^', '_', '`', '{', '|', '}', '~'
|
'}', '~'
|
||||||
]
|
]
|
||||||
|
|
||||||
LENGTH = int(sys.argv[1]) if len(sys.argv) > 1 else 6
|
LENGTH = int(sys.argv[1]) if len(sys.argv) > 1 else 6
|
||||||
|
|
||||||
URL = "https://api.random.org/json-rpc/2/invoke"
|
|
||||||
|
|
||||||
PAYLOAD = {
|
|
||||||
"jsonrpc": "2.0",
|
|
||||||
"method": "generateIntegers",
|
|
||||||
"params": {
|
|
||||||
"apiKey": "1b426e57-4fdd-4c3e-92d5-eefcba185690",
|
|
||||||
"n": 5 * LENGTH,
|
|
||||||
"min": 1,
|
|
||||||
"max": 6,
|
|
||||||
"replacement": True,
|
|
||||||
"base": 10
|
|
||||||
},
|
|
||||||
"id": 10110
|
|
||||||
}
|
|
||||||
|
|
||||||
HEADERS = {'content-type': "application/json", 'cache-control': "no-cache"}
|
|
||||||
|
|
||||||
CHT = []
|
CHT = []
|
||||||
WORD = []
|
WORD = []
|
||||||
|
|
||||||
RESPONSE = requests.request("POST",
|
|
||||||
URL,
|
|
||||||
data=json.dumps(PAYLOAD),
|
|
||||||
headers=HEADERS)
|
|
||||||
DATA = json.loads(RESPONSE.text)['result']['random']['data']
|
|
||||||
|
|
||||||
for i in range(LENGTH):
|
for i in range(LENGTH):
|
||||||
ID = int(''.join(str(d) for d in DATA[i * 5:i * 5 + 5]))
|
ID = random.SystemRandom().randint(0, 8191)
|
||||||
SELECT = DW[DW['id'] == ID]
|
CHT.append(DW['cht'].values[ID])
|
||||||
CHT.append(SELECT['cht'].values[0])
|
WORD.append(DW['word'].values[ID])
|
||||||
WORD.append(SELECT['word'].values[0])
|
|
||||||
|
|
||||||
PAYLOAD['params']['n'] = 1
|
ID = random.SystemRandom().randint(0, 31)
|
||||||
PAYLOAD['params']['min'] = 0
|
|
||||||
PAYLOAD['params']['max'] = 41
|
|
||||||
RESPONSE = requests.request("POST",
|
|
||||||
URL,
|
|
||||||
data=json.dumps(PAYLOAD),
|
|
||||||
headers=HEADERS)
|
|
||||||
DATA = json.loads(RESPONSE.text)
|
|
||||||
ID = DATA['result']['random']['data'][0]
|
|
||||||
REQUESTS_LEFT = DATA['result']['requestsLeft']
|
|
||||||
|
|
||||||
print(' '.join(CHT))
|
print(' '.join(CHT))
|
||||||
print(SEPARATOR[ID].join(WORD))
|
print(SEPARATOR[ID].join(WORD))
|
||||||
print('Request Left: ' + str(REQUESTS_LEFT))
|
|
||||||
|
27
dwg8k.py
27
dwg8k.py
@ -1,27 +0,0 @@
|
|||||||
import random
|
|
||||||
import sys
|
|
||||||
|
|
||||||
import pandas as pd
|
|
||||||
|
|
||||||
DW = pd.read_csv('pinyin8k.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))
|
|
15970
pinyin.wordlist
15970
pinyin.wordlist
File diff suppressed because it is too large
Load Diff
8193
pinyin8k.wordlist
8193
pinyin8k.wordlist
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user