1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-05 08:37:46 +00:00

Nupass refactor 20230501 (#473)

* Refactor nupass.nu

Major refactor for more flexibility

To allow number of words to be specified, one solution is to add random 
words, symbols, & numbers to lists, then operate on the lists.
You can combine lists with the ++ operator, then use shuffle on them,
as well as various other methods.

* Update ReadMe.md

Updated to match latest version, adding some new sample commands

Last version `nupass 4` meant "generate password with 3 words of length <=4".
This version `nupass 4` means "generate password with 4 words".
Length can be specified with `-l`, so: `nupass 4 -l 8` means "generate password with 4 words of length <=8".

* Update ReadMe.md

Screenshot showing new version's output
This commit is contained in:
Rick Cogley 2023-05-01 20:10:19 +09:00 committed by GitHub
parent 1099c9461e
commit 112d8b2f7e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 26 deletions

View file

@ -1,6 +1,6 @@
# Nushell Password Generator "nupass"
This nushell command randomly retrieves three words from a dictionary file (English with Japanese words added by @rickcogley) less than or equal to a given parameter's length, formats the words randomly with capitalization, then separates the words with some random symbols and numbers to return a password.
This nushell command randomly retrieves a specified number of words from a dictionary file (English with Japanese words added by @rickcogley) less than or equal to a given parameter's length, formats the words randomly with capitalization, then separates the words with some random symbols and numbers to return a password.
To use:
@ -20,10 +20,11 @@ http get https://raw.githubusercontent.com/RickCogley/jpassgen/master/genpass-di
let dictfile = $"/path/to/my/genpass-dict-jp"
```
5. Confirm the symbols are what you want to use, and edit to taste:
5. Confirm and edit the default symbols list and diceware delimiter:
```
let symbolchars = "!@#$%^&*()_-+[]"
--symbols (-s): string = "!@#$%^&()_-+[]{}" # Symbols to use in password
--delimiter (-m): string = "-" # Delimiter for diceware
```
6. Load the script with `use` in your `config.nu`, something like:
@ -40,12 +41,16 @@ Reload nu, then run it to test:
nupass -h
nupass 5
nupass 6 --debug
nupass 3 -d
nupass 8 -v diceware
nupass 8 -v diceware -m _
nupass 4 -v mixnmatch
nupass 6 -v alphanum
nupass 5 -l 8
```
### Testing
If you're making changes to the script while testing, just re-source the script by doing:
If you're making changes to the script while testing, you can just re-source the script by doing:
`use nupass.nu`
@ -53,7 +58,7 @@ If you're making changes to the script while testing, just re-source the script
### Caveats
I've been scripting for quite a long time, but not in nu. Input appreciated to make this more nu-esque!
I've been scripting for quite a long time, but not in nu. Input appreciated to make this more nu-esque! The script is in a decent place as of the 20230501 version.
Obviously you can just use the `random chars` or `random integers` commands but I like to have words I can read in my passwords, and I think those generated by this script have sufficient entropy.
@ -61,6 +66,7 @@ This command doesn't let you specify a precise length.
### Acknowledgements
Thanks everyone on Discord for putting up with and answering my nubie questions @amtoine, @fdncred, @jelle, and for the feedback after try number 1.
Thanks everyone on Discord for putting up with and answering my nubie questions @amtoine, @fdncred, @jelle, @sygmei, @kubouch and for the feedback after try number 1.
<img width="576" alt="image" src="https://user-images.githubusercontent.com/512328/235383307-d3f3d65d-c184-4dfa-9fe9-677b677d8531.png">
<img width="1041" alt="image" src="https://user-images.githubusercontent.com/512328/231930563-4da63f8c-d9de-4620-901e-a39ed32b049f.png">