想问一下 如何利用java.security.secureRandom生成指定长度的盐 用于sha1 加密?

java.security.secureRandom生成的盐可靠么?谢谢

public class SaltGenerate { public static void mainString[] args throws UnsupportedEncodingException { Random ranGen = new SecureRandom; byte[] aesKey = new byte[20]; ranGen.nextBytesaesKey; StringBuffer hexString = new StringBuffer; for int i = 0; i < aesKey.length; i++ { String hex = Integer.toHexString0xff & aesKey[i]; if hex.length == 1 hexString.append0; hexString.appendhex; } System.out.printlnhexString; } }

发表评论

电子邮件地址不会被公开。 必填项已用*标注