diff --git a/src/helma/util/MD5Encoder.java b/src/helma/util/MD5Encoder.java new file mode 100644 index 00000000..f213c58e --- /dev/null +++ b/src/helma/util/MD5Encoder.java @@ -0,0 +1,37 @@ +package helma.util; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + + +public class MD5Encoder { + + private static MessageDigest md; + + /** used by commandline script to create admin username & password */ + public static void main ( String args[] ) throws Exception { + if ( args.length < 2 ) { + System.out.println( "\n\nUsage: helma.util.MD5Encoder "); + System.out.println( "Output:"); + System.out.println( "adminUsername="); + System.out.println( "adminPassword=\n"); + System.exit(0); + } + System.out.println( "adminUsername=" + encode(args[0]) ); + System.out.println( "adminPassword=" + encode(args[1]) ); + } + + public static String encode(String str) throws Exception { + md = MessageDigest.getInstance("MD5"); + byte[] b = md.digest(str.getBytes()); + StringBuffer buf = new StringBuffer(); + for ( int i=0; i