public static String getJschFingerprint(byte[] keyBlob) throws Exception {
final String[] fingerPrintChars = {
"0","1","2","3","4","5","6","7","8","9", "a","b","c","d","e","f"
};
HASH hash = new MD5();
hash.init();
hash.update(keyBlob, 0, keyBlob.length);
byte[] foo = hash.digest();
StringBuffer sb = new StringBuffer();
int bar;
for(int i = 0; i < foo.length; i++){
bar = foo[i]&0xff;
sb.append(fingerPrintChars[(bar>>>4)&0xf]);
sb.append(fingerPrintChars[(bar)&0xf]);
if(i + 1 < foo.length) {
sb.append(":");
}
}
return sb.toString();
}
java类com.jcraft.jsch.HASH的实例源码
KeyFormatTest.java 文件源码
项目:httpsig-java
阅读 20
收藏 0
点赞 0
评论 0
SecurityUtils2.java 文件源码
项目:dohko
阅读 23
收藏 0
点赞 0
评论 0
public static String getFingerPrint(final HASH hash, final byte[] data)
{
checkNotNull(hash);
checkNotNull(data);
try
{
hash.init();
hash.update(data, 0, data.length);
byte[] digest = hash.digest();
StringBuffer sb = new StringBuffer();
int offset;
for (int i = 0; i < digest.length; i++)
{
offset = digest[i] & 0xff;
sb.append(CHARS[(offset >>> 4) & 0xf]);
sb.append(CHARS[(offset) & 0xf]);
if (i + 1 < digest.length)
{
sb.append(":");
}
}
return sb.toString();
}
catch (Exception exception)
{
return "???";
}
}
SecurityUtils2.java 文件源码
项目:dohko
阅读 25
收藏 0
点赞 0
评论 0
public static HASH md5()
{
return new com.jcraft.jsch.jce.MD5();
}