Skip to content

Instantly share code, notes, and snippets.

@Jaymo
Created February 29, 2016 08:22
Embed
What would you like to do?
private static final String RANDOM_ALGORITHM = "SHA1PRNG";
public static final int IV_LENGTH = 16;
private byte[] generateIv() throws NoSuchAlgorithmException, NoSuchProviderException {
SecureRandom random = SecureRandom.getInstance(RANDOM_ALGORITHM);
byte[] iv = new byte[IV_LENGTH];
random.nextBytes(iv);
return iv;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment