Linux 下AES报错

http://blog.csdn.net/hbcui1984/article/details/5753083


public static SecretKey getSecretKey(String password) throws NoSuchAlgorithmException {
		KeyGenerator kgen = KeyGenerator.getInstance("AES");
			kgen.init(128, new SecureRandom(password.getBytes()));
		return kgen.generateKey();
	}

// 修改后
public static SecretKey getSecretKey(String password) throws NoSuchAlgorithmException {
		KeyGenerator kgen = KeyGenerator.getInstance("AES");
		SecureRandom secure = SecureRandom.getInstance("SHA1PRNG");
		secure.setSeed(password.getBytes());
		kgen.init(128, secure);
		return kgen.generateKey();
	}

你可能感兴趣的:(Linux 下AES报错)