Base 64 Encoding Equilant to base64_encode(pack("H*",$sha1Signature))

Hi,

Can anyone please give equilant to the following php code in C#?

[php]$sha1Signature = sha1($toEncrypt)
//This will give b14dcc7842a53f1ec7a621e77c106dfbe8283779
//Encode the signature using Base64 before transmitting.

$base64Sha1Signature = base64_encode(pack(“H*”,$sha1Signature));
//This will give sU3MeEKlPx7HpiHnfBBt++goN3k=

My code is calculting SHA1 fine but Base 64 Encoding Result is different. When I send “b14dcc7842a53f1ec7a621e77c106dfbe8283779” to the following function it gives “ZmVkMzg5ZjJlNjM0ZmE2YjYyYmRmYmZhZmQwNWJlNzYxMTc2Y2VlOQ==” but I want it to be “sU3MeEKlPx7HpiHnfBBt++goN3k=”.

static public string EncodeTo64(string toEncode)
{
byte[] encbuff = System.Text.Encoding.ASCII.GetBytes(toEncode);
return Convert.ToBase64String(encbuff);
}[/php]

Thanks.

Kind Regards,

Sol

Sponsor our Newsletter | Privacy Policy | Terms of Service