红联Linux门户
Linux帮助

AES Linux解密出错

发布时间:2014-08-01 09:48:48来源:linux网站作者:lovemelovemycode

出于兴趣,最近看了一下AES加密解密方面的一些东西,代码是JAVA写的,在Windows正常运行,到Linux上报javax.crypto.BadPaddingException: Given final block not properly

padded 。


解决方法:

KeyGenerator keyGen = KeyGenerator.getInstance("AES");

String pwd = "passordgggggg";

SecureRandom random=SecureRandom.getInstance("SHA1PRNG");

random.setSeed(pwd.getBytes());

keyGen.init(128, random);