Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6230021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:40:20+00:00 2026-05-24T09:40:20+00:00

As service provider has given me the following php code, which I need to

  • 0

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;
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:40:21+00:00Added an answer on May 24, 2026 at 9:40 am

    It’s basically calling sha1 method on the concatenated array values | separated:

    sha1("123456|242342|199|EUR|subject1|34g1asda4524tgw");

    I’m no C# expert, but I guess having to do that in C# is trivial 🙂


    Here are some reference results for you:

    >> $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
    
    >> $aData;
    array (
      'merchant_id' => 'your merchant ID',
      'project_id' => 'your project ID',
      'amount' => 'amount',
      'currency_code' => 'currency code',
      'purpose_1' => 'subject line1',
      'merchant_key' => 'your merchant key',
    )
    
    >> implode('|',$aData);
    'your merchant ID|your project ID|amount|currency code|subject line1|your merchant key'
    
    >> sha1(implode('|',$aData));
    '65f23ce1507167668691445bd35451e4c6b0572b'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to implement a delegate Service provider by overriding the bean definition for
Does it make sense to use RIA Services as a service provider to an
I've implemented a WMI provider (Window service, Instance, Methods and Properties provider). It works
I have a service that accepts callbacks from a provider. Motivation : I do
I'm connecting to a web service hosted by a third-party provider. I've added a
Basically, some GoDaddy DNS help text has me scratching my head. Godaddy's DNS service
I have to implement a spring security piece which has more than 1 parameter
I have a working WCF Data Service built on a Linq2Sql data provider. Things
I've run across an interesting PHP/SOAP error that has me stymied. After searching I
I'm writing a PHP client to a C#/WCF web service. The parameters for some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.