Skip to content

Instantly share code, notes, and snippets.

@quonic
Created May 26, 2017 13:39
Show Gist options
  • Save quonic/d5e4aa1552da2adeba1899909604b022 to your computer and use it in GitHub Desktop.
Save quonic/d5e4aa1552da2adeba1899909604b022 to your computer and use it in GitHub Desktop.
function New-Password{
Param(
[int]
$min=6,
[int]
$max=8,
[int]
$Count = 1,
[string]
$Dictionary=".\dict.txt"
)
if($Dictionary -and (Test-Path $Dictionary)){
#Nothing to do
}else{
Invoke-WebRequest -Uri https://raw.githubusercontent.com/first20hours/google-10000-english/master/google-10000-english-usa.txt -OutFile $Dictionary
}
$words = Get-Content -Path $Dictionary
if($Count -gt 1){
$i = 1
do{
$part1 = [System.Windows.Forms.Cursor]::Position
$part2 = Get-Date
$Seed = $part2.Millisecond + $part2.Minute + $part2.Hour - (($part1.X * $part1.X) * $part1.Y)
[string]$password = Get-Random -InputObject $words -SetSeed $Seed -Count $(Get-Random -Minimum $min -Maximum $max)
Write-Output -InputObject $password
$i++
}until($i -ge $Count)
}else{
$part1 = [System.Windows.Forms.Cursor]::Position
$part2 = Get-Date
$Seed = $part2.Millisecond + $part2.Minute + $part2.Hour - (($part1.X * $part1.X) * $part1.Y)
[string]$password = Get-Random -InputObject $words -SetSeed $Seed -Count $(Get-Random -Minimum $min -Maximum $max)
Write-Output -InputObject $password
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment