Skip to content

Instantly share code, notes, and snippets.

@bricef
Created April 22, 2012 12:22
Show Gist options
  • Save bricef/2463908 to your computer and use it in GitHub Desktop.
Save bricef/2463908 to your computer and use it in GitHub Desktop.
Generating an IV in Java
import java.security.SecureRandom;
public static byte[] genIV(int len) throws Exception{
byte[] arr = new byte[len];
SecureRandom prng = SecureRandom.getInstance("SHA1PRNG");
prng.nextBytes(arr);
return arr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment