Last active
August 2, 2018 14:31
-
-
Save brettmillerb/63da9063aa724d5bec69827e1e6b7bc7 to your computer and use it in GitHub Desktop.
Generate New Passphrases instead of Passwords
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function New-PassPhrase { | |
<# | |
.SYNOPSIS | |
Generate PassPhrase for account logins | |
.DESCRIPTION | |
Generate a PassPhrase from a pre-defined list of words instead of using random character passwords | |
.PARAMETER Length | |
Length of PassPhrase to be generated | |
.PARAMETER Delimiter | |
The Delimiter to be used when outputting the PassPhrase. If no delimiter is specified then a hyphen is used '-' | |
.EXAMPLE | |
New-PassPhrase -Length 25 | |
.EXAMPLE | |
New-PassPhrase -Length 25 -Delimiter ';' | |
.NOTES | |
NCSC UK Guidance on Secure Passwords | |
https://www.ncsc.gov.uk/guidance/password-guidance-simplifying-your-approach | |
#> | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory, | |
Position = 1)] | |
[int] | |
$PassPhraseLength, | |
[Parameter(Position = 2)] | |
[char] | |
$Delimiter = '-' | |
) | |
begin { | |
$wordlist = Get-Content -Path $PSScriptRoot\configuration\pnemonicwordlist.txt | |
} | |
process { | |
$phrasearr = @() | |
while ($phrase.length -lt $length) { | |
$phrasearr += $wordlist | Get-Random | |
$phrase = $phrasearr -join '' | |
} | |
} | |
end { | |
$phrasearr -join $Delimiter | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment