<div dir="ltr">Thanks Viktor, <br>for assistance .....<br>The embedded private key "skeleton" is only for visualisation purposes; No it will not.<br><br><br>the openssl command returns binary. <br>so i can do .But they are still coming out different.<br><br><span style="color:rgb(255,255,255);font-family:Menlo,Monaco,Consolas,"Courier New",monospace;font-size:15px;white-space:pre-wrap;background-color:rgb(51,51,51);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">openssl base64 -in /tmp/sign.sha256 -out <signature></span><br></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Aug 1, 2018 at 4:28 PM Viktor Dukhovni <<a href="mailto:openssl-users@dukhovni.org">openssl-users@dukhovni.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, Aug 01, 2018 at 09:24:38AM +0100, timmy pony wrote:<br>
<br>
> I have tried this<br>
><br>
> openssl dgst -sha256 -sign my_private.key -out /tmp/sign.sha256 codeTosign.txt<br>
<br>
This produces raw binary output, no base64 encoding.  What is the<br>
content of the file "codeToSign.txt"?  Post the output of:<br>
<br>
    od -tx1 < /tmp/codeToSign.txt<br>
<br>
> public class SHA256RSA {<br>
> <br>
>     public static void main(String[] args) throws Exception {<br>
>         String input = "sample input";<br>
<br>
This input has no newline ending, perhaps the disk file does.<br>
<br>
>         // Not a real private key! Replace with your private key!<br>
>         String strPk = "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9"<br>
>                 + "w0BAQEFAASCBKkwggSlAgEAAoIBAQDJUGqaRB11KjxQ\nKHDeG"<br>
>                 + "........................................................"<br>
>                 + "Ldt0hAPNl4QKYWCfJm\nNf7Afqaa/RZq0+y/36v83NGENQ==\n"<br>
>                 + "-----END PRIVATE KEY-----\n";<br>
<br>
I sure hope your production code will *NOT* have the private key<br>
embedded in the executable.<br>
<br>
>         String base64Signature = signSHA256RSA(input,strPk);<br>
>         System.out.println("Signature="+base64Signature);<br>
<br>
This outputs a signature encoded in base64.<br>
<br>
-- <br>
        Viktor.<br>
-- <br>
openssl-users mailing list<br>
To unsubscribe: <a href="https://mta.openssl.org/mailman/listinfo/openssl-users" rel="noreferrer" target="_blank">https://mta.openssl.org/mailman/listinfo/openssl-users</a><br>
</blockquote></div>