Saturday, March 30, 2013

Same text, different Signature with each execution


I´m using GWT 2.5 and I´m trying to sign a text, that is always the same.

Code (exceptions ommited):

public String sign(String text) {
String sign = null;
Signature signer = Signature.getInstance("SHA1withRSA");
sign = Base64Utils.toBase64(signer.sign());
return sign;

I put some System.out.println to see values. First are 8 first bytes from clear text (variable text). Second is clear text passed to base64 using Base64Utils (just in case Base64Utils returns different values). Third is 8 first bytes from signed text. 

I put different executions:

Execution 1

Execution 2


Execution 3

I can´t put private key but I can assure you (breakpoint see) that is always the same.

So problem is clear. The method Signature.getInstance is returning a different Signature construction that makes signed text different each time.

Does anyone know why this happens?

Thanks in advance.

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment