mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-26 09:53:57 +01:00
Improve list-random-passwords.ps1 and list-random-pins.ps1
This commit is contained in:
parent
c5fa0b574d
commit
62741a1fba
@ -1,21 +1,20 @@
|
||||
#!/usr/bin/pwsh
|
||||
<#
|
||||
.SYNTAX list-random-passwords.ps1
|
||||
.SYNTAX list-random-passwords.ps1 [<password-length>] [<columns>] [<rows>]
|
||||
.DESCRIPTION prints a list of random passwords
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
$PasswordLength = 15
|
||||
$Columns = 6
|
||||
$Lines = 24
|
||||
param([int]$PasswordLength = 15, [int]$Columns = 6, [int]$Rows = 26)
|
||||
|
||||
$MinCharCode = 33
|
||||
$MaxCharCode = 126
|
||||
|
||||
try {
|
||||
write-output ""
|
||||
$Generator = New-Object System.Random
|
||||
for ($j = 0; $j -lt $Lines; $j++) {
|
||||
for ($j = 0; $j -lt $Rows; $j++) {
|
||||
$Line = ""
|
||||
for ($k = 0; $k -lt $Columns; $k++) {
|
||||
for ($i = 0; $i -lt $PasswordLength; $i++) {
|
||||
|
@ -6,22 +6,17 @@
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
param([int]$PinLength = 5, [int]$Columns = 12, [int]$Rows = 24)
|
||||
|
||||
function GeneratePIN {
|
||||
$Generator = New-Object System.Random
|
||||
for ($i = 0; $i -lt $PinLength; $i++) {
|
||||
$PIN += [char]$Generator.next(48,57)
|
||||
}
|
||||
return $PIN
|
||||
}
|
||||
param([int]$PinLength = 5, [int]$Columns = 12, [int]$Rows = 26)
|
||||
|
||||
try {
|
||||
write-output ""
|
||||
$Generator = New-Object System.Random
|
||||
for ($j = 0; $j -lt $Rows; $j++) {
|
||||
$Line = ""
|
||||
for ($k = 0; $k -lt $Columns; $k++) {
|
||||
$Line += GeneratePIN
|
||||
for ($i = 0; $i -lt $PinLength; $i++) {
|
||||
$Line += [char]$Generator.next(48,57)
|
||||
}
|
||||
$Line += " "
|
||||
}
|
||||
write-output $Line
|
||||
|
Loading…
Reference in New Issue
Block a user