52 lines
884 B
Go
52 lines
884 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"golang.org/x/crypto/ssh/terminal"
|
|
|
|
passage "git.bullercodeworks.com/brian/passage-go"
|
|
)
|
|
|
|
func main() {
|
|
var pin, door string
|
|
p := passage.CreatePassage("")
|
|
for i := 1; i < len(os.Args); i++ {
|
|
switch i {
|
|
case 1:
|
|
pin = os.Args[i]
|
|
p.SetPin(pin)
|
|
fmt.Println("Checksum: " + p.GetChecksumAsString())
|
|
case 2:
|
|
door = os.Args[i]
|
|
}
|
|
}
|
|
getInput := (pin == "" && door == "")
|
|
for getInput {
|
|
if pin == "" {
|
|
fmt.Print("Pin: ")
|
|
pinBt, _ := terminal.ReadPassword(0)
|
|
fmt.Println("")
|
|
pin = string(pinBt)
|
|
}
|
|
if pin == "" {
|
|
continue
|
|
} else {
|
|
p.SetPin(pin)
|
|
fmt.Println("Checksum: " + p.GetChecksumAsString())
|
|
}
|
|
if door == "" {
|
|
fmt.Print("Door (leave empty to re-enter pin): ")
|
|
fmt.Scanln(&door)
|
|
}
|
|
if door == "" {
|
|
pin = ""
|
|
} else {
|
|
getInput = false
|
|
}
|
|
}
|
|
|
|
fmt.Println(p.GetPassword(door))
|
|
}
|