public final class MD5Crypt extends Object
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: $
Version: $Revision: 1.1 $
Last Mod Date: $Date: 2004/02/04 08:10:35 $
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 ----------------------------------------------------------------------------
Constructor and Description |
---|
MD5Crypt() |
Modifier and Type | Method and Description |
---|---|
static String |
crypt(String password)
This method actually generates a OpenBSD/FreeBSD/Linux PAM compatible
md5-encoded password hash from a plaintext password and a salt.
|
static String |
crypt(String password,
String salt)
This method actually generates a OpenBSD/FreeBSD/Linux PAM compatible
md5-encoded password hash from a plaintext password and a salt.
|
static void |
main(String[] argv)
Command line test rig.
|
public static void main(String[] argv) throws NoSuchAlgorithmException
NoSuchAlgorithmException
public static final String crypt(String password) throws NoSuchAlgorithmException
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 passwordNoSuchAlgorithmException
public static final String crypt(String password, String salt) throws NoSuchAlgorithmException
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.NoSuchAlgorithmException
Copyright © 2012–2017 Apache Software Foundation. All rights reserved.