package de.gehis.aida.admin.crypt; import java.io.*; import java.security.*; public class EncryptPassword { public static void main(String args[]) { if (args.length != 2) { System.err.println("usage: PasswordTest password testvalue"); System.exit(1); } byte[] buf= new byte[args[0].length()]; buf = args[0].getBytes(); //args[0].getBytes(0, args[0].length(), buf, 0); MessageDigest algorithm=null; try { algorithm = MessageDigest.getInstance("SHA-1"); }catch (NoSuchAlgorithmException e) { System.out.println(e); } algorithm.reset(); algorithm.update(buf); byte[] digest1 = algorithm.digest(); algorithm.reset(); buf= new byte[args[1].length()]; buf= args[1].getBytes(); algorithm.update(buf); byte[] digest2 = algorithm.digest(); StringBuffer digbuf = new StringBuffer(); for (int i=0; i < digest1.length; i++) { System.out.print(digest1[i]); digbuf.append(digest1[i]); } System.out.println(); System.out.println(digbuf +" :: digbuf"); for (int i=0; i < digest2.length; i++) { System.out.print(digest2[i]); } System.out.println(); if(digest1.length != digest2.length) { System.out.println("They do not match!"); System.exit(0); } for(int i=0; i