PoshCode Archive  Artifact [c212e97fbe]

Artifact c212e97fbe25623c98d4b25a815191ca76d1e43337c2a5c3cde5e8905ff7e561:

  • File Convert-ToCHexString.ps1 — part of check-in [85c0fb39ea] at 2018-06-10 12:56:33 on branch trunk — Converts an input string into its C ASCI Hex equivalent, useful for converting a string into an unsigned char array (user: CrazyDave size: 618)

# encoding: ascii
# api: powershell
# title: Convert-ToCHexString
# description: Converts an input string into its C ASCI Hex equivalent, useful for converting a string into an unsigned char array
# version: 0.1
# type: function
# author: CrazyDave
# license: CC0
# function: Convert-ToCHexString
# x-poshcode-id: 1155
# x-derived-from-id: 4069
# x-archived: 2017-04-08T23:41:30
# x-published: 2010-06-10T13:24:00
#
#
function Convert-ToCHexString 
{
	param ([String] $str) 
	$ans = ''
	[System.Text.Encoding]::ASCII.GetBytes($str) | % { $ans += "0x{0:X2}, " -f $_ }
	return $ans.Trim(' ',',')
}