mirror of
https://github.com/fiatjaf/nak.git
synced 2024-11-22 08:19:06 -05:00
fix nak key encrypt reading from stdin.
This commit is contained in:
parent
1ba39ca7d7
commit
9f98a0aea3
7
key.go
7
key.go
|
@ -72,20 +72,19 @@ var encrypt = &cli.Command{
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
var content string
|
keys := make([]string, 0, 1)
|
||||||
var password string
|
var password string
|
||||||
switch c.Args().Len() {
|
switch c.Args().Len() {
|
||||||
case 1:
|
case 1:
|
||||||
content = ""
|
|
||||||
password = c.Args().Get(0)
|
password = c.Args().Get(0)
|
||||||
case 2:
|
case 2:
|
||||||
content = c.Args().Get(0)
|
keys = append(keys, c.Args().Get(0))
|
||||||
password = c.Args().Get(1)
|
password = c.Args().Get(1)
|
||||||
}
|
}
|
||||||
if password == "" {
|
if password == "" {
|
||||||
return fmt.Errorf("no password given")
|
return fmt.Errorf("no password given")
|
||||||
}
|
}
|
||||||
for sec := range getSecretKeysFromStdinLinesOrSlice(c, []string{content}) {
|
for sec := range getSecretKeysFromStdinLinesOrSlice(c, keys) {
|
||||||
ncryptsec, err := nip49.Encrypt(sec, password, uint8(c.Int("logn")), 0x02)
|
ncryptsec, err := nip49.Encrypt(sec, password, uint8(c.Int("logn")), 0x02)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
lineProcessingError(c, "failed to encrypt: %s", err)
|
lineProcessingError(c, "failed to encrypt: %s", err)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user