As service provider has given me the following php code, which I need to replicate in C#
$aData = array('merchant_id' => 'your merchant ID', // 123456
'project_id' => 'your project ID', // 242342
'amount' => 'amount', // 199 = 1,99 EUR
'currency_code' => 'currency code', // EUR
'purpose_1' => 'subject line1',
'merchant_key' => 'your merchant key'); //34g1asda4524tgw
$sHash = sha1(implode('|', $aData));
As I only have very basic php knowledge, I would be very greatful if somebody could help me convert this into c#.
My first thought was to create a dictionary, but the pipe in the implode function is bothering me a bit. So what kind of array/list should I be using?
Then how would I "implode" the list?
SOLUTION
Thanks goes to @andreas and @Mchl! The following code returns a hash of 65f23ce1507167668691445bd35451e4c6b0572b.
//test
string merchantId = "your merchant ID";
string projectId = "your project ID";
string amount = "amount";
string currency = "currency code";
string invoiceId = "subject line1";
string merchantKey = "your merchant key";
string imploded = merchantId + "|" + projectId + "|" + amount + "|" + currency + "|" + invoiceId + "|"+merchantKey;
byte[] arrayData = Encoding.ASCII.GetBytes(imploded);
byte[] hash = SHA1.ComputeHash(arrayData);
//return hash.ToString();
string result = null;
string temp = null;
for (int i = 0; i < hash.Length; i++)
{
temp = Convert.ToString(hash[i], 16);
if (temp.Length == 1)
temp = "0" + temp;
result += temp;
}