Codelog

foreach(Snippet aSnippet in CodeLog){ aSnippet.GetSolution(); }

Archive for the ‘encryption’ tag

Password Encryption Using SHA1 (MD5) - JAVA

with 3 comments

Here’s is a program where the password stored in the code is encoded by SHA1, It accepts the input from user computes the SHA1 digest and check if it is the same as the set Password. I have set the Password to - password


import java.io.Console;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class SHA1Pwd {

public static void main(String[] args) {

char[] passwordChar = null;
Console console = System.console();
MessageDigest md = null;
String encodedSetPwdInHexString = “5:BA:A6:1E:4C:9B:93:F3:F0:68:22:50:B6:CF:83:31:B7:EE:68:FD:8″;

//digest value of the string - password. change it to your required password digest.

try {

md = MessageDigest.getInstance(”SHA1″); // can be replaced with MD5
// SHA1 has fewer collisions in comparison with MD5.

Read the rest of this entry »

Written by danish

September 13th, 2008 at 9:53 am

Posted in Java

Tagged with , , ,