Tag: salt

如何获取/设置JdbcRealm的salt

我试图使用Shiro JdbcRealm和SHA256 hashedcredentialsMatcher。 我需要更新遗留数据库并为每个用户分配适当的盐(通过批处理例程)。 如何使用Shiro框架获取/设置给定帐户的盐?

AES 256位加密 – java.security.InvalidAlgorithmParameterException:错误的IV长度:必须是16个字节长

以下是我的加密逻辑。 虽然我的IV是16字节长,但我仍然会收到无效IV长度的错误。 非常感谢任何帮助 @Override public String encrypt(String dataToEncrypt, String IV) throws Exception{ if(encryptionKey.length() < 10){ encryptionKey = generateEncryptionKey().toString(); } System.out.println("number of IV bytes is "+IV.length()+" "+IV); Cipher cipher = Cipher.getInstance(encrpytionAlgo); SecretKey key = new SecretKeySpec(encryptionKey.getBytes(Charset.forName("UTF-8")), "AES"); cipher.init(Cipher.ENCRYPT_MODE, key,new IvParameterSpec(IV.getBytes(Charset.forName("UTF-8")))); byte[] encryptedTextBytes = cipher.doFinal(dataToEncrypt.getBytes(Charset.forName("UTF-8"))); return new Base64().encodeAsString(encryptedTextBytes); } IV和密钥生成逻辑 @Override public String generateRandomIV(){ Random random = […]