Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Base62 {
- param(
- [ValidateRange(0, [int]::MaxValue)]
- [int]
- $NumberInput
- )
- process {
- [string]$Symbols = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
- [int]$Radix = $Symbols.Length
- [string]$Output = ""
- Do {
- $Output = '{0}{1}' -f $Output, $Symbols[($NumberInput % $Radix)]
- $NumberInput = [Math]::Floor([decimal]($NumberInput /= $Radix))
- }
- While ($NumberInput -gt 0)
- $Output
- }
- }
- Base62 187621 # => 9OM
- Base62 237860461 # => 3n26g
- Base62 2187521 # => B4b9
- Base62 18752 # => sS4
Advertisement
Add Comment
Please, Sign In to add comment