05-01-2014 03:20 AM
Hi,
Am trying to do base64 encoding on a script. I have a local variable in my CPO process which has the script. The script contains nearly 20 lines. I use the following power shell script for base64 encoding,
[System.Convert]::ToBase64String([System.Text.Encoding]::UNICODE.GetBytes($(args[0]))
But I get an error stating, "Multi-line argument is not supported". I tried enabling the check for multiline in the local varaible, but it didnt work either.Can you please suggest how to resolve this?
Anish
05-08-2014 09:10 AM
I have completed the base64 encoding of the UserData. Am using a utility tool which encodes the data to a base64 format. I invoke the tool through a powershell command of CPO process. But when ipass this to calculate the AWS signature, its running for nearly 30 minutes without any output. When i reduce my UserData length to around 4 to 5 lines, it calculates the signature perfectly. Am using a powershell script to calculate the signature. The same below,
$secret, $data, $awshost = $args
[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null
$params = $data.replace("%%","%")
$verb = "POST"
$url = "/"
$data = [String]::Format("{0}`n{1}`n{2}`n{3}", $verb, $awshost, $url, $params)
$encoder = New-Object System.Text.UTF8Encoding
$sha256 = New-Object System.Security.Cryptography.HMACSHA256
$sha256.Key = $encoder.GetBytes($secret)
$hmac = $sha256.ComputeHash($encoder.GetBytes($data))
$enc = [System.Convert]::ToBase64String($hmac)
$hash = [System.Uri]::EscapeDataString($enc)
$null = [Reflection.Assembly]::LoadWithPartialName("System.Web")
$hash = [System.Web.HttpUtility]::UrlEncode($enc)
$hash.toString()
Could you please suggest how to resolve this. Is there any other command to create the signature?
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide