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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:19:02+00:00 2026-06-08T11:19:02+00:00

I have the following piece of Java code that I would like to convert

  • 0

I have the following piece of Java code that I would like to convert to a shell script using openssl command line tool:

java.security.Signature sig = java.security.Signature.getInstance("SHA1WithRSA");
sig.initSign(privateKey);
sig.update(data);
byte[] signatureBytes = sig.sign();

So far I have tried the following:

openssl dgst -sha1 -binary < data.der > data.hash
openssl rsautl -sign -inkey private.key -keyform pem -in data.hash -out data.rsa

However it does not produce the same output. I guess it might have something to do with formats or padding etc. What do I need to do to correct the openssl script?

Both codes above produce a repeatable result but the result is different between java and the openssl shell script.

All suggestions are appreciated.

Kind regards
Jens

  • 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-08T11:19:05+00:00Added an answer on June 8, 2026 at 11:19 am

    I actually found the answer myself at last.

    The following openssl command will perform SHA1WithRSA and generates the same result as the Java code:

    openssl sha1 -sign private.key -out data.rsa data.der
    

    As simple as that, but it was quite hard to find on the web

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

Sidebar

Related Questions

I have the following piece of Java code that reads strings from CSV file.
I'd like to convert a piece of Java code which looks like the following
I have the following piece of pseudo-C/Java/C# code: int a[]= { 30, 20 };
I have the following piece of code that takes in some words, stores them
A newbie question. I have the following piece of Java code: import acm.program.*; import
I have the following piece of code that is taken from a mock exam
I have the following piece of code in a java application Thread.currentThread().sleep(10000); However eclipse
I have the following piece of code that checks whether port 443 is open
I have following piece of code: It compiles without problems under gcc-3.4, gcc-4.3, intel
I have following piece of code : public Hashmap<String,String> tempmap = new HashMap<String,String>(); and

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.