Created
April 19, 2016 20:12
-
-
Save Hexalon/4a7573182007b3950fce381f9936c634 to your computer and use it in GitHub Desktop.
Converts input string to a hex value
This file contains hidden or 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
<# | |
.NOTES | |
=========================================================================== | |
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2016 v5.2.117 | |
Created on: 3/22/2016 10:15 | |
Created by: Colin Squier <[email protected]> | |
Filename: StringToHex.ps1 | |
=========================================================================== | |
.DESCRIPTION | |
Converts input string to a hex value. | |
#> | |
$StringToConvert = Read-Host -Prompt "Enter string to convert to hex" | |
$StringArray = $StringToConvert.ToCharArray() | |
Foreach ($Element in $StringArray) | |
{ | |
$HexValue = $HexValue + [System.String]::Format("{0:X}", [System.Convert]::ToUInt32($Element)) | |
$StringLength++ | |
} | |
$StringLength = $StringLength * 2 | |
Write-Output "Input string: $StringToConvert, Hex value: $HexValue, String length: $StringLength" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment