Renamed to list-passwords.ps1

This commit is contained in:
Markus Fleschutz
2020-12-14 07:37:21 +00:00
parent 9699b7e29b
commit 754a5c1899
3 changed files with 10 additions and 36 deletions

View File

@ -1,15 +1,16 @@
#!/snap/bin/powershell
# Syntax: ./passwords.ps1
# Syntax: ./list-passwords.ps1
# Description: generates and prints a list of new passwords
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
$NumPasswords = 20
$CharsPerPassword = 15
$MinCharCode = 33
$MaxCharCode = 126
$NumLines = 24
$NumColumns = 6
function new_password() {
$password = ""
@ -21,9 +22,12 @@ function new_password() {
}
try {
for ($j = 0; $j -lt $NumPasswords; $j++) {
$password = new_password
write-output $password
for ($j = 0; $j -lt $NumLines; $j++) {
for ($k = 0; $k -lt $NumColumns; $k++) {
$password = new_password
Write-Host -NoNewline "$password "
}
Write-Host ""
}
exit 0
} catch {

View File

@ -1,29 +0,0 @@
#!/snap/bin/powershell
# Syntax: ./password.ps1
# Description: generates and prints a single new password
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
$CharsPerPassword = 15
$MinCharCode = 33
$MaxCharCode = 126
function new_password() {
$password = ""
$generator = New-Object System.Random
for ($i = 0; $i -lt $CharsPerPassword; $i++) {
$password = $password +[char]$generator.next($MinCharCode,$MaxCharCode)
}
return $password
}
try {
$password = new_password
write-output $password
exit 0
} catch {
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}