shiro加密底层

protected byte[] hash(byte[] bytes, byte[] salt, int hashIterations) throws UnknownAlgorithmException {
MessageDigest digest = this.getDigest(this.getAlgorithmName());
if (salt != null) {
digest.reset();
digest.update(salt);
}

byte[] hashed = digest.digest(bytes);
int iterations = hashIterations - 1;

for(int i = 0; i < iterations; ++i) {
digest.reset();
hashed = digest.digest(hashed);
}

return hashed;
}
posted @ 2022-04-23 23:50  暗影霹雳神  阅读(37)  评论(0编辑  收藏  举报