2025-01-29 03:50:43 +00:00
|
|
|
#!/usr/bin/env nu
|
2024-10-14 09:54:24 +00:00
|
|
|
|
2025-01-29 03:50:43 +00:00
|
|
|
# Generate a passphrase.
|
|
|
|
def "main passphrase" --wrapped [
|
|
|
|
...rest: string # Additional arguments to be added to the passphrase generation command.
|
|
|
|
] {
|
|
|
|
gopass pwgen --xkcd --lang en --one-per-line --xkcdnumbers --xkcdcapitalize ...$rest | head -n1
|
2024-10-14 09:54:24 +00:00
|
|
|
}
|
|
|
|
|
2025-01-29 03:50:43 +00:00
|
|
|
# Generate a password.
|
|
|
|
def "main password" --wrapped [
|
|
|
|
...rest # Additional arguments to be added to the password generation command.
|
|
|
|
] {
|
|
|
|
gopass pwgen --symbols --one-per-line ...$rest | head -n1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Generate a randomly-generated base64-encoded string.
|
|
|
|
def "main secret" [] {
|
|
|
|
dd if=/dev/urandom bs=32 count=1 2>/dev/null | base64
|
|
|
|
}
|
|
|
|
|
|
|
|
# Encode the given string to argon2.
|
|
|
|
def "main encode-argon2" [
|
|
|
|
string # The string to be encoded.
|
|
|
|
] {
|
|
|
|
$string | argon2 (openssl rand -base64 32) -e -id -k 65540 -t 3 -p 4
|
|
|
|
}
|
|
|
|
|
|
|
|
# A toolbelt for anything secret-related. It can be used to generate a
|
|
|
|
# passphrase, password, and encode into several variants.
|
|
|
|
def "main" [] {
|
|
|
|
help main | print -e
|
|
|
|
exit 0
|
2024-10-14 09:54:24 +00:00
|
|
|
}
|