admin管理员组文章数量:1663645
2023年12月12日发(作者:)
javashahash_java中实现SHA1安全哈希算法
博主人很懒,直接就贴代码了~~
import eDigest;
/**
* 安全哈希算法 SHA1
* @author lenovo
*
*/
public class SHA1 {
private static final char[] HEX_DIGITS = { ‘0’, ‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’, ‘a’, ‘b’,
‘c’, ‘d’,
‘e’, ‘f’ };
private static String getFormattedText(byte[] bytes) {
int len = ;
StringBuilder buf = new StringBuilder(len * 2);
// 把密文转换成十六进制的字符串形式
for (int j = 0; j < len; j++) {
(HEX_DIGITS[(bytes[j] >> 4) & 0x0f]);
(HEX_DIGITS[bytes[j] & 0x0f]);
}
return ng();
}
public static String encode(String str) {
if (str == null) {
return null;
}
try {
MessageDigest messageDigest = tance(“SHA1”);
(es());
return getFormattedText(());
} catch (Exception e) {
throw new RuntimeException(e);
}
}}
版权声明:本文标题:javashahash_java中实现SHA1安全哈希算法 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/xitong/1702346950a2282.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论