public String sha1(String password,int passformat,String passwordsalt) throws NoSuchAlgorithmException, UnsupportedEncodingException{
if(passformat==0)
{return password;
}
byte[] bIn =password.getBytes(Charset.forName("utf-16le"));
byte[] bSalt = Base64.decodeBase64(passwordsalt);
byte[] bAll = new byte[bSalt.length + bIn.length];
byte[] bRet = null;
System.arraycopy(bSalt, 0, bAll, 0, bSalt.length);
System.arraycopy(bIn, 0, bAll, bSalt.length, bIn.length);
if (passformat == 1)
{
MessageDigest mdTemp = MessageDigest.getInstance("SHA1");
mdTemp.update(bAll);
bRet = mdTemp.digest();
}
else
{
}
return Base64.encodeBase64String(bRet);
本文介绍了一种使用SHA1算法进行密码加密的方法,包括不同格式的密码处理方式、盐值的应用以及Base64编码的使用。
207

被折叠的 条评论
为什么被折叠?



