adjsuted pw gen
This commit is contained in:
parent
b866811ab8
commit
0f8b325246
2 changed files with 33 additions and 3 deletions
4
pw_generaturr/nimbledeps/nimbledata2.json
Normal file
4
pw_generaturr/nimbledeps/nimbledata2.json
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"reverseDeps": {}
|
||||||
|
}
|
|
@ -1,11 +1,16 @@
|
||||||
import ../../globurrl
|
|
||||||
|
#import ../../globurrl
|
||||||
|
|
||||||
import httpclient
|
import httpclient
|
||||||
import json
|
import json
|
||||||
import strutils
|
import strutils
|
||||||
import random
|
import random
|
||||||
|
import parseopt
|
||||||
|
import os
|
||||||
|
|
||||||
var length = 4
|
var length = 4
|
||||||
|
var number = 10
|
||||||
|
var word_len = 5
|
||||||
|
|
||||||
proc getNumber(size: int = 4): string =
|
proc getNumber(size: int = 4): string =
|
||||||
var num = ""
|
var num = ""
|
||||||
|
@ -21,17 +26,38 @@ proc parsePw(body: string) =
|
||||||
var p = pass.getStr.capitalizeAscii
|
var p = pass.getStr.capitalizeAscii
|
||||||
p &= getNumber(length)
|
p &= getNumber(length)
|
||||||
echo p
|
echo p
|
||||||
|
|
||||||
|
|
||||||
proc getPW() =
|
proc getPW() =
|
||||||
var c = newHttpClient()
|
var c = newHttpClient()
|
||||||
try:
|
try:
|
||||||
let resp = c.get("https://random-word-api.herokuapp.com/word?length=5")
|
let resp = c.get("https://random-word-api.herokuapp.com/word?number=" & $number & "&length=" & $word_len)
|
||||||
if resp.status == $Http200:
|
if resp.status == $Http200:
|
||||||
parsePw(resp.body)
|
parsePw(resp.body)
|
||||||
|
|
||||||
except:
|
except:
|
||||||
echo getCurrentExceptionMsg()
|
echo getCurrentExceptionMsg()
|
||||||
|
|
||||||
|
proc parseArgs() =
|
||||||
|
var p = initOptParser(commandLineParams())
|
||||||
|
while true:
|
||||||
|
p.next()
|
||||||
|
case p.kind
|
||||||
|
of cmdEnd: break
|
||||||
|
of cmdShortOption, cmdLongOption:
|
||||||
|
if p.val == "":
|
||||||
|
#echo "Option: ", p.key
|
||||||
|
discard
|
||||||
|
else:
|
||||||
|
#echo "Option and value: ", p.key, ", ", p.val
|
||||||
|
case p.key
|
||||||
|
of "length":
|
||||||
|
word_len = parseInt(p.val)
|
||||||
|
of "number":
|
||||||
|
number = parseInt(p.val)
|
||||||
|
of cmdArgument:
|
||||||
|
#echo "Argument: ", p.key
|
||||||
|
discard
|
||||||
|
|
||||||
if isMainModule:
|
if isMainModule:
|
||||||
|
parseArgs()
|
||||||
getPW()
|
getPW()
|
||||||
|
|
Loading…
Reference in a new issue