wood burning stoves 2.0*
The moose likes Java in General and the fly likes Hash SHA1 String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Hash SHA1 String" Watch "Hash SHA1 String" New topic
Author

Hash SHA1 String

Patrick McDonogh
Ranch Hand

Joined: Oct 13, 2005
Posts: 89
Hi all,

I am trying to create a SHA1 hash of a String Object. I have got as far as getting a DigestMethod object but from here i have no idea how to hash the string. The code i am using to get the digest method is shown below.

String hashingString = "I want to be hashed";
String providerName = System.getProperty("jsr105Provider", "org.jcp.xml.dsig.internal.dom.XMLDSigRI");
XMLSignatureFactory factory =
XMLSignatureFactory.getInstance("DOM", (Provider) Class.forName(providerName).newInstance());

DigestMethod method = factory.newDigestMethod(DigestMethod.SHA1,null);

Does anyone know how to get a hash of this string?
Have i started off correctly?

Thankyou in advance for your help.

Patrick
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39552
    
  27
Is there a particular reason you're using the XML-Security classes? Because the standard class libraries contain everything you need, along the following lines:


Ping & DNS - updated with new look and Ping home screen widget
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hash SHA1 String
 
Similar Threads
Doubt in Cryptography
Certificate Signature Validation
NUll pointer exception in XML sig program
Digital Signature Validation
Double Hashing - hashing SHA1 with MD5