Private/ConvertTo-JumbledString.ps1
function ConvertTo-JumbledString { <# .SYNOPSIS Gets an string and randomly changes character's position. .DESCRIPTION This function gets an string as an input and change each charachter's position randomly. Usually when you want an string does not have a reqular output form, this function will be used. .EXAMPLE PS> convertto-JumbledString -InputString "PowerShell" hrweSoellP #> [CmdletBinding()] [OutputType([System.String])] param ( [string]$InputString ) $charArray = $InputString.ToCharArray() $random = New-Object System.Random Write-Verbose -Message "Start to change character's position randomly" for ($i = 0; $i -lt $InputString.Length; $i++) { $j = $random.Next(0, $InputString.Length) $temp = $charArray[$i] $charArray[$i] = $charArray[$j] $charArray[$j] = $temp } return -join $charArray } |