Tabnine Logo
MD5Crypt.crypt
Code IndexAdd Tabnine to your IDE (free)

How to use
crypt
method
in
org.sonatype.security.ldap.dao.password.hash.MD5Crypt

Best Java code snippets using org.sonatype.security.ldap.dao.password.hash.MD5Crypt.crypt (Showing top 6 results out of 315)

origin: org.sonatype.nexus/nexus-ldap-common

@Override
public String encodePassword(String password, Object salt) {
 try {
  return "{CRYPT}" + md5Crypt.crypt(password);
 }
 catch (NoSuchAlgorithmException e) {
  throw new RuntimeException("No MD5 Algorithm", e);
 }
}
origin: org.sonatype.nexus.plugins.ldap/ldap-common

public String encodePassword( String password, Object salt )
{
  try
  {
    return "{CRYPT}" + md5Crypt.crypt( password );
  }
  catch ( NoSuchAlgorithmException e )
  {
    throw new RuntimeException( "No MD5 Algorithm", e );
  }
}
origin: org.sonatype.nexus/nexus-ldap-common

@Override
public boolean isPasswordValid(String encPassword, String inputPassword, Object salt) {
 try {
  String encryptedPassword = encPassword;
  if (encryptedPassword.startsWith("{crypt}") || encryptedPassword.startsWith("{CRYPT}")) {
   encryptedPassword = encryptedPassword.substring("{crypt}".length());
  }
  int lastDollar = encryptedPassword.lastIndexOf('$');
  String realSalt = encryptedPassword.substring("$1$".length(), lastDollar);
  String check = md5Crypt.crypt(inputPassword, realSalt);
  return check.equals(encryptedPassword);
 }
 catch (NoSuchAlgorithmException e) {
  throw new RuntimeException("No MD5 Algorithm", e);
 }
}
origin: org.sonatype.nexus.plugins.ldap/ldap-common

public boolean isPasswordValid( String encPassword, String inputPassword, Object salt )
{
  try
  {
    String encryptedPassword = encPassword;
    if ( encryptedPassword.startsWith( "{crypt}" ) || encryptedPassword.startsWith( "{CRYPT}" ) )
    {
      encryptedPassword = encryptedPassword.substring( "{crypt}".length() );
    }
    int lastDollar = encryptedPassword.lastIndexOf( '$' );
    String realSalt = encryptedPassword.substring( "$1$".length(), lastDollar );
    String check = md5Crypt.crypt( inputPassword, realSalt );
    return check.equals( encryptedPassword );
  }
  catch ( NoSuchAlgorithmException e )
  {
    throw new RuntimeException( "No MD5 Algorithm", e );
  }
}
origin: org.sonatype.nexus/nexus-ldap-common

/**
 * Encrypts a password using FreeBSD-style md5-based encryption
 *
 * @param password The cleartext password to be encrypted
 * @return The encrypted password, or an empty string on error
 * @throws java.security.NoSuchAlgorithmException
 *          if java.security
 *          does not support MD5
 */
public final String crypt(String password) throws java.security.NoSuchAlgorithmException {
 StringBuilder salt = new StringBuilder();
 SecureRandom randgen = new SecureRandom();
 while (salt.length() < 8) {
  int index = (int) (randgen.nextFloat() * itoa64.length());
  salt.append(itoa64.substring(index, index + 1));
 }
 return crypt(password, salt.toString());
}
origin: org.sonatype.nexus.plugins.ldap/ldap-common

/**
 * Encrypts a password using FreeBSD-style md5-based encryption
 * @param password The cleartext password to be encrypted
 * @throws java.security.NoSuchAlgorithmException if java.security
 *        does not support MD5
 * @return The encrypted password, or an empty string on error
 */
public final String crypt(String password) throws java.security.NoSuchAlgorithmException
{
  StringBuilder salt = new StringBuilder();
  SecureRandom randgen = new SecureRandom();
  while (salt.length() < 8)
  {
    int index = (int) (randgen.nextFloat() * itoa64.length());
    salt.append(itoa64.substring(index, index+1));
  }
  return crypt(password, salt.toString());
}
org.sonatype.security.ldap.dao.password.hashMD5Cryptcrypt

Javadoc

Encrypts a password using FreeBSD-style md5-based encryption

Popular methods of MD5Crypt

  • cryptTo64

Popular in Java

  • Updating database using SQL prepared statement
  • setScale (BigDecimal)
  • getExternalFilesDir (Context)
  • getSupportFragmentManager (FragmentActivity)
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • JButton (javax.swing)
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now