Results 1 to 1 of 1
Thread: Hashing problem
- 07-23-2009, 12:56 PM #1
Member
- Join Date
- Jun 2009
- Posts
- 17
- Rep Power
- 0
Hashing problem
For my program i ask for a Username and Password so they can log in. However i hash the password before sending it anywhere.
However after typing is the word 'pass' four times and reading the results on my termnial i have the following four outputs.Java Code:import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.logging.Level; import java.util.logging.Logger; public class PassHasher{ public static String PassHasher(String input) { try { MessageDigest md = MessageDigest.getInstance("SHA1"); md.reset(); byte[] buffer = input.getBytes(); md.update(buffer); byte[] digest = md.digest(); String hexStr = ""; for (int i = 0; i < digest.length; i++) { hexStr += Integer.toString((digest[i] & 0xff) + 0x100, 16).substring(1); } return hexStr; } catch (NoSuchAlgorithmException ex) { Logger.getLogger(PassHasher.class.getName()).log(Level.SEVERE, null, ex); } return ""; } }
395f718302d95fbc3dbcc8315048ff08a58ee2bf
fca7974df7d038d96da5fec6c473c7e6397cc6ff
5cc9a9ec2df98e2c00356a14d39c2b6e2797b8ce
b6ae915dcd296de752d8fc2c9ce6a94060c0c127
The password is stored in a java swing password field and the following is called to extract it
String pass = Pass.getPassword().toString();
Then it;s put into the hasher and the result printed to terminal. Can someone please tell me why it's not working.
Similar Threads
-
Hashing and Searching Benchmarking
By peterdfl in forum New To JavaReplies: 0Last Post: 12-07-2008, 10:28 PM -
Hashing in Java
By ajaykushwaha in forum New To JavaReplies: 1Last Post: 11-17-2008, 12:51 PM -
Hash table with double hashing
By Java Tip in forum java.langReplies: 0Last Post: 04-12-2008, 08:43 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks