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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:41:34+00:00 2026-06-12T08:41:34+00:00

I reviewed many forums and examples, but none helped me. I need verify signature

  • 0

I reviewed many forums and examples, but none helped me. I need verify signature from any webservice. I have test.crt file with public key for verify.

static bool Verify(string text, string signature)
{
  X509Certificate2 cert = new X509Certificate2(
      HttpContext.Current.Server.MapPath("test-server.cert"));
  RSACryptoServiceProvider csp = (RSACryptoServiceProvider) cert.PublicKey.Key;

  // Hash the data
  SHA1Managed sha1 = new SHA1Managed();
  UnicodeEncoding encoding = new UnicodeEncoding();
  byte[] data = encoding.GetBytes(text);
  byte[] sign = Convert.FromBase64String(signature);
  byte[] hash = sha1.ComputeHash(data);

  return csp.VerifyHash(hash, CryptoConfig.MapNameToOID("SHA1"), sign);
}

But result is always false 🙁

I have an OpenSSL example:

openssl base64 -d -in signature -out signature.bin
openssl dgst -sha1 -verify test-server.pub -signature signature.bin from_gateway
  • 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-12T08:41:35+00:00Added an answer on June 12, 2026 at 8:41 am

    I suspect the use UnicodeEncoding could be the reason for failures. As demonstrated below the bytes of ASCIIEncoding and UnicodeEncoding are not same for the reason ASCII is a 8bit encoding and in Windows Unicode encoding is 16bit wide. In your other question Can not get signature you’ve used the ASCIIEncoding. So assuming signature is computed on the ASCIIEncoding bytes of the text/string and verify using UnicodeEncoding obviously will not match.

    string text = "Hello";
    Console.WriteLine("ASCIIEncoding bytes length: {0}", new ASCIIEncoding().GetBytes(text).Length);
    Console.WriteLine("UnicodeEncoding bytes length: {0}", new UnicodeEncoding().GetBytes(text).Length);
    

    Outputs

    ASCIIEncoding bytes length: 5
    UnicodeEncoding bytes length: 10
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have reviewed a few Struts 1 vs 2 questions on SO but none
I've reviewed many websites and youtube videos that have IOS 5 storyboarding information. Most
I have reviewed numerous reports of this error but the solutions I have seen
I have reviewed a lot of information about these things, but can't understand what
I've reviewed many other posts on here and have become pretty familiar with the
I reviewed similar questions but could not find an answer to my specific quandry.
I've reviewed all the similar questions here, but I can't for the life of
I know there's a ton of similar questions on here but I reviewed a
Thank you for submitting APPNAME_HERE. We have reviewed your application and have determined that
I didn't plan project correctly from beginning so I ended up having many SQL

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.