当前位置: 首页>>代码示例>>Java>>正文


Java Md5Crypt.md5Crypt方法代码示例

本文整理汇总了Java中org.apache.commons.codec.digest.Md5Crypt.md5Crypt方法的典型用法代码示例。如果您正苦于以下问题:Java Md5Crypt.md5Crypt方法的具体用法?Java Md5Crypt.md5Crypt怎么用?Java Md5Crypt.md5Crypt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.codec.digest.Md5Crypt的用法示例。


在下文中一共展示了Md5Crypt.md5Crypt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: PasswordEncrypt

import org.apache.commons.codec.digest.Md5Crypt; //导入方法依赖的package包/类
public PasswordEncrypt(final String key) {
	final byte[] keyBytes = key.getBytes(US_ASCII);
	this.md5 = Md5Crypt.md5Crypt(keyBytes.clone());
	this.apr1 = Md5Crypt.apr1Crypt(keyBytes.clone());
	this.sha256 = Sha2Crypt.sha256Crypt(keyBytes.clone());
	this.sha512 = Sha2Crypt.sha512Crypt(keyBytes.clone());
	Arrays.fill(keyBytes, (byte) 0);
}
 
开发者ID:ggrandes,项目名称:sftpserver,代码行数:9,代码来源:PasswordEncrypt.java

示例2: authenticateMd5Passwords

import org.apache.commons.codec.digest.Md5Crypt; //导入方法依赖的package包/类
public static boolean authenticateMd5Passwords(final String authValue, final Iterable<String> passwords) {
    final Matcher matcher = MD5_PATTERN.matcher(authValue);
    if (matcher.matches()) {
        final String known = matcher.group(1);
        final String salt = matcher.group(2);

        for (String password : passwords) {
            final String offered = Md5Crypt.md5Crypt(password.getBytes(), salt);
            if (known.equals(offered)) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:rpsl4j,项目名称:rpsl4j-parser,代码行数:16,代码来源:PasswordHelper.java

示例3: checkPassword

import org.apache.commons.codec.digest.Md5Crypt; //导入方法依赖的package包/类
public static boolean checkPassword(final String crypted, final String key) {
	String crypted2 = null;
	if (crypted == null)
		return false;
	if (crypted.length() < 24)
		return false;
	if (crypted.charAt(0) != '$')
		return false;
	final int offset2ndDolar = crypted.indexOf('$', 1);
	if (offset2ndDolar < 0)
		return false;
	final int offset3ndDolar = crypted.indexOf('$', offset2ndDolar + 1);
	if (offset3ndDolar < 0)
		return false;
	final String salt = crypted.substring(0, offset3ndDolar + 1);
	final byte[] keyBytes = key.getBytes(US_ASCII);
	if (crypted.startsWith("$1$")) { // MD5
		crypted2 = Md5Crypt.md5Crypt(keyBytes.clone(), salt);
	} else if (crypted.startsWith("$apr1$")) { // APR1
		crypted2 = Md5Crypt.apr1Crypt(keyBytes.clone(), salt);
	} else if (crypted.startsWith("$5$")) { // SHA2-256
		crypted2 = Sha2Crypt.sha256Crypt(keyBytes.clone(), salt);
	} else if (crypted.startsWith("$6$")) { // SHA2-512
		crypted2 = Sha2Crypt.sha512Crypt(keyBytes.clone(), salt);
	}
	Arrays.fill(keyBytes, (byte) 0);
	if (crypted2 == null)
		return false;
	return crypted.equals(crypted2);
}
 
开发者ID:ggrandes,项目名称:sftpserver,代码行数:31,代码来源:PasswordEncrypt.java

示例4: encode

import org.apache.commons.codec.digest.Md5Crypt; //导入方法依赖的package包/类
@NonNull
@Override
public String encode(@NonNull String text) {
    return Md5Crypt.md5Crypt(text.getBytes());
}
 
开发者ID:tranleduy2000,项目名称:text_converter,代码行数:6,代码来源:Md5HashFunction.java

示例5: generate

import org.apache.commons.codec.digest.Md5Crypt; //导入方法依赖的package包/类
/**
 * Creates a new md5 salted hash based from user id and user email.
 */
public static String generate(UserData userData) {
    String raw = Long.toString(userData.getUserId()) + "" + userData.getEmail();
    return Md5Crypt.md5Crypt(raw.getBytes());
}
 
开发者ID:sliechti,项目名称:feedrdr,代码行数:8,代码来源:CookieUtils.java

示例6: hashMd5Password

import org.apache.commons.codec.digest.Md5Crypt; //导入方法依赖的package包/类
public static final String hashMd5Password(final String cleantextPassword) {
    return Md5Crypt.md5Crypt(cleantextPassword.getBytes());
}
 
开发者ID:rpsl4j,项目名称:rpsl4j-parser,代码行数:4,代码来源:PasswordHelper.java


注:本文中的org.apache.commons.codec.digest.Md5Crypt.md5Crypt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。