本文整理汇总了Java中com.trilead.ssh2.crypto.digest.MD5类的典型用法代码示例。如果您正苦于以下问题:Java MD5类的具体用法?Java MD5怎么用?Java MD5使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MD5类属于com.trilead.ssh2.crypto.digest包,在下文中一共展示了MD5类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: generateKeyFromPasswordSaltWithMD5
import com.trilead.ssh2.crypto.digest.MD5; //导入依赖的package包/类
private static byte[] generateKeyFromPasswordSaltWithMD5(byte[] password, byte[] salt, int keyLen)
throws IOException
{
if (salt.length < 8)
throw new IllegalArgumentException("Salt needs to be at least 8 bytes for key generation.");
MD5 md5 = new MD5();
byte[] key = new byte[keyLen];
byte[] tmp = new byte[md5.getDigestLength()];
while (true)
{
md5.update(password, 0, password.length);
md5.update(salt, 0, 8); // ARGH we only use the first 8 bytes of the
// salt in this step.
// This took me two hours until I got AES-xxx running.
int copy = (keyLen < tmp.length) ? keyLen : tmp.length;
md5.digest(tmp, 0);
System.arraycopy(tmp, 0, key, key.length - keyLen, copy);
keyLen -= copy;
if (keyLen == 0)
return key;
md5.update(tmp, 0, tmp.length);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:PEMDecoder.java
示例2: generateKeyFromPasswordSaltWithMD5
import com.trilead.ssh2.crypto.digest.MD5; //导入依赖的package包/类
private static byte[] generateKeyFromPasswordSaltWithMD5(byte[] password,
byte[] salt, int keyLen) throws IOException {
if (salt.length < 8)
throw new IllegalArgumentException(
"Salt needs to be at least 8 bytes for key generation.");
MD5 md5 = new MD5();
byte[] key = new byte[keyLen];
byte[] tmp = new byte[md5.getDigestLength()];
while (true) {
md5.update(password, 0, password.length);
md5.update(salt, 0, 8); // ARGH we only use the first 8 bytes of the
// salt in this step.
// This took me two hours until I got AES-xxx running.
int copy = (keyLen < tmp.length) ? keyLen : tmp.length;
md5.digest(tmp, 0);
System.arraycopy(tmp, 0, key, key.length - keyLen, copy);
keyLen -= copy;
if (keyLen == 0)
return key;
md5.update(tmp, 0, tmp.length);
}
}
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:32,代码来源:PEMDecoder.java
示例3: getFingerprint
import com.trilead.ssh2.crypto.digest.MD5; //导入依赖的package包/类
private String getFingerprint(byte[] serverHostKey) {
MD5 md5 = new MD5();
md5.update(serverHostKey);
byte[] fingerprint = new byte[16];
md5.digest(fingerprint);
StringBuilder buf = new StringBuilder();
for( byte b : fingerprint ) {
if(buf.length()>0) buf.append(':');
buf.append(String.format("%02x",b));
}
return buf.toString();
}
开发者ID:hudson3-plugins,项目名称:ec2-plugin,代码行数:15,代码来源:HostKeyVerifierImpl.java
注:本文中的com.trilead.ssh2.crypto.digest.MD5类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论