totptool/cmds/code.nim

26 lines
478 B
Nim
Raw Normal View History

2015-09-15 01:49:40 +00:00
import otp
import os
when isMainModule:
var
args = commandLineParams()
if args.len != 1:
quit "I need a machine name"
try:
var
keyFileName = args[0]
fin = open getEnv("HOME") / "life" / "crypto" / "totp" / keyFileName
key = fin.readLine
totp = newTotp key
echo totp.now()
except:
echo getCurrentExceptionMsg()
quit "Couldn't do that for " & args[0] & ". Does that machine exist in the store?"
else:
quit "invalid"