Skip to content

Instantly share code, notes, and snippets.

@brettmillerb
Last active August 2, 2018 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brettmillerb/63da9063aa724d5bec69827e1e6b7bc7 to your computer and use it in GitHub Desktop.
Save brettmillerb/63da9063aa724d5bec69827e1e6b7bc7 to your computer and use it in GitHub Desktop.
Generate New Passphrases instead of Passwords
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