Skip to content

Instantly share code, notes, and snippets.

@Jaymo
Created February 29, 2016 08:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jaymo/6b683c6aee3ba949533c to your computer and use it in GitHub Desktop.
Save Jaymo/6b683c6aee3ba949533c to your computer and use it in GitHub Desktop.
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