As much as I hate it, sometimes providing passwords to people has to be done electronically. When I do that I try to remove any ambiguity that might be created by the font, user etc. and provide a phonetic translation of the string. For things like 0 and O or l and I which might not be obvious at first.
The function below can take a single string or be piped a string array. I could get crazy with this later to support other languages by making some nested arrays but for now it only supports English.
function Get-PhoneticString{
param(
[parameter(ValueFromPipeline=$true, Mandatory=$true)]
[string]$StringToExplode,
[string]$Delimiter = " - "
)
process{
# Alphabetic conversions using military phonetics
$phoneticAlphabet = @{
"a" = "alfa"; "b" = "bravo"; "c" = "charlie"; "d" = "delta"; "e" = "echo";
"f" = "foxtrot"; "g" = "golf"; "h" = "hotel"; "i" = "india"; "j" = "juliett";
"k" = "kilo"; "l" = "lima"; "m" = "mike"; "n" = "november"; "o" = "oscar";
"p" = "papa"; "q" = "quebec"; "r" = "romeo"; "s" = "sierra"; "t" = "tango";
"u" = "uniform"; "v" = "victor"; "w" = "whiskey"; "x" = "x-ray"; "y" = "yankee";
"z" = "zulu"
}
$numberAsString = @{
"0"="zero"; "1"="one"; "2"="two"; "3"="three"; "4"="four"
"5"="five"; "6"="six"; "7"="seven"; "8"="eight"; "9"="nine"
}
$symbolAsString = @{
"!" = "Exclamation Mark"; '"' = "Double Quote"; "#" = "Number Sign"; "$" = "Dollar"; "%" = "Percent"; "&" = "Ampersand"
"'" = "Single Quote"; "(" = "Left Parenthesis"; ")" = "Right Parenthesis"; "*" = "Asterisk"; "+" = "Plus"
"," = "Comma"; "-" = "Minus"; "." = "Period"; "/" = "Slash"; ":" = "Colon"; ";" = "Semicolon"; "<" = "Less Than"
"=" = "Equality Sign"; ">" = "Greater Than"; "?" = "Question Mark"; "@" = "At Sign"; "[" = "Left Square Bracket"
"\" = "Backslash"; "]" = "Right Square Bracket"; "^" = "Caret"; "_" = "Underscore"; '`' = "Grave / Accent"
"{" = "Left Curly Bracket"; "|" = "Vertical Bar"; "}" = "Right Curly Bracket"
}
# Convert this string into a character array. For each character find its string equivilent in one of the defined hash tables
($StringToExplode.ToCharArray() | ForEach-Object{
switch -Regex -CaseSensitive ($_){
"[a-z]"{$phoneticAlphabet."$_"}
"[A-Z]"{($phoneticAlphabet."$_").ToUpper()}
"\d"{$numberAsString."$_"}
"\s"{$_}# Return whitespace unaltered
default{ $symbolAsString."$_"}
}
}) -join $Delimiter
}
}
So a sample call and output would look like this
"K0D3R3v13w" | Get-PhoneticString
KILO - zero - DELTA - three - ROMEO - three - victor - one - three - whiskey
It only supports the basic ASCII printable character set. Any uppercase alphabetical characters will have all uppercase strings returned. If the character is not alphanumeric it will be assumed that it is a symbol in the set. If that character is not covered at all then it will show as empty in the resultant string and means something needs to be updated to account for it. Since I am using this for passwords that should cover near all supported characters.