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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:28:15+00:00 2026-05-30T05:28:15+00:00

everybody! I’m trying to digitally sign some data in C#. Everything goes without error

  • 0

everybody!

I’m trying to digitally sign some data in C#. Everything goes without error but when I want to see the results of RSACryptoServiceProvider.SignHash , I get some strange results.

Here’s My code:

    System.Security.Cryptography.X509Certificates.X509Store store = new System.Security.Cryptography.X509Certificates.X509Store(StoreName.My, StoreLocation.CurrentUser);
    store.Open(OpenFlags.ReadOnly);
    X509Certificate2Collection certCollection = store.Certificates.Find(X509FindType.FindBySubjectName, "SOME NAME", true);

    X509Certificate2Enumerator enumerator = certCollection.GetEnumerator();

    X509Certificate2 x509 = null;
    while (enumerator.MoveNext()){
       x509 = enumerator.Current;
    }

    store.Close();

    RSACryptoServiceProvider csp = null;
    csp = (RSACryptoServiceProvider)x509.PrivateKey;

    if (csp == null){
        throw new Exception("Valid certificate was not found");
    }      

    string sTestText = "SomeTestData";
    System.Text.ASCIIEncoding  encoding=new System.Text.ASCIIEncoding();  

    SHA1Managed sha1 = new SHA1Managed();
    ASCIIEncoding encoding2 = new System.Text.ASCIIEncoding();
    byte[] data = encoding2.GetBytes(sTestText);
    byte[] hash = sha1.ComputeHash(data);

    Byte[] baSignedHash = csp.SignHash(hash, CryptoConfig.MapNameToOID("SHA1"));

    string sSignedHash = System.Text.ASCIIEncoding.ASCII.GetString(baSignedHAsh);

    Console.WriteLine("sSignedHash=" + sSignedHash );

I get this text:
sSignedHash=?H↨???C↑?X !??????sPotpisaniHash=J1??Q????7 ?G??D?5?=Dc?6C????♀??j?p?♠?♥?{♫??[i?↔?????◄??;?‼?????}Sx☺>VN?i6?☻’??▲f??t@?E?↕?▬??►k??v?’???☻ GX??}x@???)??F?7TP?♂&??

I’ve tried different encodings(UTF8, ect) but no luck. Does enyone know what could be the problem?

  • 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-30T05:28:16+00:00Added an answer on May 30, 2026 at 5:28 am

    Does enyone know what could be the problem?

    Yes. You’re trying to treat opaque binary data as if it were text. It’s not.

    You could get a hex representation:

    string text = BitConverter.ToString(baSignedHash);
    

    Or a base-64 representation:

    string text = Convert.ToBase64String(baSignedHash);
    

    It’s very important to understand the difference between “binary data which is actually encoded text data” (which is where Encoding.GetString comes in) and “binary data which isn’t text” (e.g. image data, executable files, encrypted data, compressed data).

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

Sidebar

Related Questions

hope everybody is cool.I've been trying to do something with spring-hibernate but it's still
Hi everybody. The problem: elcipse-3.5.0 (Galileo) spits with an error when I try to
Heyy Everybody! I am trying to create a memory management system, so that a
everybody, I have some problem related to the jenkins and git. I created a
everybody! I'm making a Android program and I need to list some texts on
everybody, I'm beginner in programming, I've just finished my course on C++, I want
Hy everybody! I'm trying to use Childbrowser Phonegap plugin to redirect the user within
Everybody has seen a blog. They usually follow the syntax of: user.site.com But are
Hi Everybody, I have a third party library that contains an error. When I
Hello everybody I'm trying to make my own web site with framework JBoss Netty,

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.