Advertisement

09.11.2006 at 06:15AM PDT, ID: 21984745
[x]
Attachment Details

Decrypt SHA1-RSA

Asked by SkipFire in .NET

Tags: decrypt

I need to be able to decrypt a string that is encrypted with a certificate using SHA1-RSA.  This is being used to integrate a .NET application with authentication from an existing system that cannot be changed.

Please provide sample code, or a link to a sample project.  C# or VB.NET code is fine and I would prefer code that is compatible with both .NET 1.1 and .NET 2.0.  I would like to avoid third-party components as the procurement process for this client is rather slow and painful.

If it helps, the following Java code encrypted what I need to decrypt.

public String createUrlFragment(String privateKeyName, String privateKeyPassword, String authString) throws UrlAuthenticationException
{
    try
    {
      PrivateKey privateKey = (PrivateKey) _keyStore.getKey(privateKeyName, privateKeyPassword.toCharArray());
      Enumeration e = _keyStore.aliases();
      while(e.hasMoreElements())
      {
              System.out.println("alais:" + (String)e.nextElement());
      }
      if (privateKey == null)
                 throw new UrlAuthenticationException("No key " + privateKeyName + " found");
      Signature signature = Signature.getInstance("SHA1withRSA");
      signature.initSign(privateKey);
      signature.update(authString.getBytes());
      byte[] sig1 = signature.sign();
      String base64 =Base64.encodeBytes(sig1);
      String urlFragment = "user=" + URLEncoder.encode(authString,"UTF-8") + "&authSignature=" + URLEncoder.encode(base64,"UTF-8");
      return urlFragment;
    }
    catch (Exception e)
    {
      throw new UrlAuthenticationException("UrlAuthenticationException: " + e.toString());
    }
  }
}  

Start Free Trial
[+][-]09.11.2006 at 11:16AM PDT, ID: 17496636

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.20.2006 at 06:54AM PDT, ID: 17560708

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.16.2006 at 02:35PM PDT, ID: 17742719

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]10.20.2006 at 10:38AM PDT, ID: 17775500

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.20.2006 at 12:05PM PDT, ID: 17776293

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.20.2006 at 08:53PM PDT, ID: 17778697

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.20.2006 at 08:54PM PDT, ID: 17778699

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.23.2006 at 12:48PM PDT, ID: 17791118

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: .NET
Tags: decrypt
Sign Up Now!
Solution Provided By: joechina
Participating Experts: 1
Solution Grade: A
 
 
[+][-]10.24.2006 at 10:35AM PDT, ID: 17797636

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.24.2006 at 04:25PM PDT, ID: 17800172

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.24.2006 at 06:35PM PDT, ID: 17800707

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.02.2006 at 11:31AM PST, ID: 17860808

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32