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

  • SEARCH
  • Home
  • 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 586371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:06:02+00:00 2026-05-13T15:06:02+00:00

I need a PHP version of the following C# code: string dateSince = 2010-02-01;

  • 0

I need a PHP version of the following C# code:

string dateSince = "2010-02-01";
string siteID = "bash.org";
string sharedSecret = "12345"; // the same combination on my luggage!

using System.Security.Cryptography;

MD5CryptoServiceProvider x = new MD5CryptoServiceProvider();
byte[] dataBytes = System.Text.Encoding.ASCII.GetBytes(string.Format("{0}{1}{2}",   dateSince,  siteID, sharedSecret));
string result = BitConverter.ToString(x.ComputeHash(dataBytes));

… this code snippet appears to be incomplete. But here’s what I think is going on:

  1. concatenating dateSince, siteID, and sharedSecret. Stealing underpants.

  2. ???

  3. converting that string into a ascii encoded byte array.

  4. taking the MD5 hash of that array.

This mysterious BitConverter object appears to be converting that MD5 hashed array, into a string of hexadecimal numbers. According to the aforementioned doc, the value of result should look something like: “6D-E9-9A-B6-73-D8-10-79-BC-4F-EE-51-A4-84-15-D8”

Any help is greatly appreciated!!


Forgot to include this earlier. Here’s the PHP version of what I’ve written so far:

$date_since = "2010-02-01";
$site_id = "bash.org";
$shared_secret = "12345";

$initial_token = $date_since.$site_id.$shared_secret;

$ascii_version = array();
foreach($i=0; $i < strlen($initial_token); $i++) {
    $ascii_version[] = ord(substr($initial_token,$i,1));
}

$md5_version = md5(join("", $ascii_version));

$hexadecimal_bits = array();
foreach($i=0; $i < strlen($md5_version); $i++) {
   // @todo convert to hexadecimal here?
   $hexadecimal_bits[] = bin2hex(substr($md5_version,$i,1));
}

$result = join("-", $hexadecimal_bits);
  • 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-13T15:06:02+00:00Added an answer on May 13, 2026 at 3:06 pm

    I think this will work for you. It looks like the MD5CryptoServiceProvider::ComputeHash method returns an array of 16 bytes, not a string of 32 characters like the normal PHP md5() function. However, PHP’s md5() has a second optional parameter that forces “raw output”, which does correspond to the output of ComputeHash().

    $date_since = "2010-02-01";
    $site_id = "bash.org";
    $shared_secret = "12345";
    $initial_token = $date_since.$site_id.$shared_secret;
    
    //get the RAW FORMAT md5 hash
    //corresponds to the output of MD5CryptoServiceProvider::ComputeHash
    $str = md5($initial_token, true);
    $len = strlen($str);
    $hex = array();
    for($i = 0; $i < $len; $i++) {
        //convert the byte to a hex string representation (left padded with zeros)
        $hex[] = str_pad(dechex(ord($str[$i])), 2, '0', STR_PAD_LEFT);
    }
    //dump output
    echo implode("-",$hex);
    
    //outputs fe-0d-58-fd-5f-3d-83-fe-0f-6a-02-b4-94-0c-aa-7b
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 499k
  • Answers 500k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This is not pretty but it works: rm -R $(ls… May 16, 2026 at 12:45 pm
  • Editorial Team
    Editorial Team added an answer Yes. Override the base1 and base2 methods in Derived to… May 16, 2026 at 12:45 pm
  • Editorial Team
    Editorial Team added an answer No, you can't. Unfortunately, UIEvent doesn't expose any public way… May 16, 2026 at 12:45 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have the following code: if (include_once(dirname(__FILE__).'/file.php') || include_once(dirname(__FILE__).'/local/file.php') ) { This causes an
I'd like to be able to run a line of PHP code on the
I need to create a script in PHP language which performs permutation of numbers.
I'm generating an image out of text using php. My code works perfectly on
We need to have our PHP application hosted on a 64 bit Windows OS
I need to validate some user input that is encoded in UTF-8. Many have
I'm trying to mimic the json_encode bitmask flags implemented in PHP 5.3.0, here is
Today, I removed and reinstalled the latest version of lampp in order to move
I am making some changes on the live site and i constantly need to
I have two dates - a start date and an end date. I need

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.