|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--md5.MD5Crypt
This class defines a method,
crypt(), which
takes a password and a salt string and generates an OpenBSD/FreeBSD/Linux-compatible
md5-encoded password entry.
Created: 3 November 1999
Release: $Name: ganymede_001000011 $
Version: $Revision: 1.12 $
Last Mod Date: $Date: 2002/03/29 06:02:34 $
Java Code By: Jonathan Abbey, jonabbey@arlut.utexas.edu
Original C Version:
---------------------------------------------------------------------------- "THE BEER-WARE LICENSE" (Revision 42):wrote this file. As long as you retain this notice you can do whatever you want with this stuff. If we meet some day, and you think this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp ----------------------------------------------------------------------------
| Field Summary | |
private static java.lang.String |
itoa64
|
private static java.lang.String |
SALTCHARS
|
| Constructor Summary | |
MD5Crypt()
|
|
| Method Summary | |
static java.lang.String |
apacheCrypt(java.lang.String password)
This method generates an Apache MD5 compatible md5-encoded password hash from a plaintext password and a salt. |
static java.lang.String |
apacheCrypt(java.lang.String password,
java.lang.String salt)
This method actually generates an Apache MD5 compatible md5-encoded password hash from a plaintext password and a salt. |
private static int |
bytes2u(byte inp)
convert an encoded unsigned byte value into a int with the unsigned value. |
private static void |
clearbits(byte[] bits)
|
static java.lang.String |
crypt(java.lang.String password)
This method actually generates a OpenBSD/FreeBSD/Linux PAM compatible md5-encoded password hash from a plaintext password and a salt. |
static java.lang.String |
crypt(java.lang.String password,
java.lang.String salt)
This method actually generates a OpenBSD/FreeBSD/Linux PAM compatible md5-encoded password hash from a plaintext password and a salt. |
static java.lang.String |
crypt(java.lang.String password,
java.lang.String salt,
java.lang.String magic)
This method actually generates md5-encoded password hash from a plaintext password, a salt, and a magic string. |
static void |
main(java.lang.String[] argv)
Command line test rig. |
private static java.lang.String |
to64(long v,
int size)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private static final java.lang.String SALTCHARS
private static final java.lang.String itoa64
| Constructor Detail |
public MD5Crypt()
| Method Detail |
public static void main(java.lang.String[] argv)
private static final java.lang.String to64(long v,
int size)
private static final void clearbits(byte[] bits)
private static final int bytes2u(byte inp)
public static final java.lang.String crypt(java.lang.String password)
This method actually generates a OpenBSD/FreeBSD/Linux PAM compatible md5-encoded password hash from a plaintext password and a salt.
The resulting string will be in the form '$1$<salt>$<hashed mess>
password - Plaintext password
public static final java.lang.String crypt(java.lang.String password,
java.lang.String salt)
This method actually generates a OpenBSD/FreeBSD/Linux PAM compatible md5-encoded password hash from a plaintext password and a salt.
The resulting string will be in the form '$1$<salt>$<hashed mess>
password - Plaintext passwordsalt - A short string to use to randomize md5. May start with $1$, which
will be ignored. It is explicitly permitted to pass a pre-existing
MD5Crypt'ed password entry as the salt. crypt() will strip the salt
chars out properly.
public static final java.lang.String apacheCrypt(java.lang.String password)
This method generates an Apache MD5 compatible md5-encoded password hash from a plaintext password and a salt.
The resulting string will be in the form '$apr1$<salt>$<hashed mess>
password - Plaintext password
public static final java.lang.String apacheCrypt(java.lang.String password,
java.lang.String salt)
This method actually generates an Apache MD5 compatible md5-encoded password hash from a plaintext password and a salt.
The resulting string will be in the form '$apr1$<salt>$<hashed mess>
password - Plaintext passwordsalt - A short string to use to randomize md5. May start with $apr1$, which
will be ignored. It is explicitly permitted to pass a pre-existing
MD5Crypt'ed password entry as the salt. crypt() will strip the salt
chars out properly.
public static final java.lang.String crypt(java.lang.String password,
java.lang.String salt,
java.lang.String magic)
This method actually generates md5-encoded password hash from a plaintext password, a salt, and a magic string.
There are two magic strings that make sense to use here.. '$1$' is the magic string used by the FreeBSD/Linux/OpenBSD MD5Crypt algorithm, and '$apr1$' is the magic string used by the Apache MD5Crypt algorithm.
The resulting string will be in the form '<magic><salt>$<hashed mess>
password - Plaintext password @param salt A short string to
use to randomize md5. May start with the magic string, which
will be ignored. It is explicitly permitted to pass a
pre-existing MD5Crypt'ed password entry as the salt. crypt()
will strip the salt chars out properly.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||