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 8352195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:53:43+00:00 2026-06-09T08:53:43+00:00

Possible Duplicate: C# SHA-1 vs. PHP SHA-1…Different Results? I am trying to find out

  • 0

Possible Duplicate:
C# SHA-1 vs. PHP SHA-1…Different Results?

I am trying to find out what the PHP sha1(string,true); equivalent method is in C#. I tried searching a lot and also tried writing some code, but couldn’t find any solution. Can anyone tell me how to get sha1 in row binary format with a length of 20, like the PHP function: SHA1 in the PHP manual?

In PHP:

sha1($sampletext, true);

In C#:

string sampletext= "text";
SHA1 hash = SHA1CryptoServiceProvider.Create();
byte[] plainTextBytes = Encoding.ASCII.GetBytes(dataString);
byte[] hashBytes = hash.ComputeHash(plainTextBytes);

Both return a different output.

Thanks

  • 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-06-09T08:53:46+00:00Added an answer on June 9, 2026 at 8:53 am

    This IDEOne test seems to produce the same output as using UTF-8 encoding for the hash in C#:

    string sampletext = "text";
    System.Security.Cryptography.SHA1 hash = System.Security.Cryptography.SHA1CryptoServiceProvider.Create();
    byte[] plainTextBytes = Encoding.UTF8.GetBytes(sampletext);
    byte[] hashBytes = hash.ComputeHash(plainTextBytes);
    
    foreach (byte b in hashBytes) {
        Console.Write(string.Format("{0:x2}", b));
    }
    

    This will be platform-specific depending on how the PHP handles it. It may even be ASCII from some of the documentation. It’s all to do with character encoding.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Find out the instance id from within an ec2 machine I am
Possible Duplicate: Find the “#” character in a string with Javascript How do I
Possible Duplicate: Is SHA-1 secure for password storage? I am new to encryption and
Possible Duplicate: How do I make a request using HTTP basic authentication with PHP
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: PHP get all arguments as array? Within a javascript function arguments always
Possible Duplicate: regex for URL including query string I have a text or message.
Possible Duplicate: php == vs === operator Reference - What does this symbol mean
Possible Duplicate: How to call a JavaScript function from PHP? I have a php
Possible Duplicate: Why is String.Concat not optimized to StringBuilder.Append? One day I was ranting

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.