Skip to content

Instantly share code, notes, and snippets.

@rbonifacio
Created July 5, 2022 13:57
Show Gist options
  • Save rbonifacio/d5d88e833fecfc9ace8360dda68d847a to your computer and use it in GitHub Desktop.
Save rbonifacio/d5d88e833fecfc9ace8360dda68d847a to your computer and use it in GitHub Desktop.
Code based on a CryptoAnalys test case. CogniCrypt still raises a warning.
public static void main(String args[]) throws Exception {
KeyGenerator keyGenerator0 = KeyGenerator.getInstance("AES");
SecretKey secretKey = keyGenerator0.generateKey();
int num = 2024;
SecureRandom secureRandom0 = SecureRandom.getInstance("SHA1PRNG");
byte[] genSeed = secureRandom0.generateSeed(num);
GCMParameterSpec gCMParameterSpec0 = new GCMParameterSpec(96, genSeed);
byte[] plainText = "secret".getBytes();
Cipher cipher0 = Cipher.getInstance("AES/GCM/NoPadding");
cipher0.init(1, secretKey, gCMParameterSpec0);
byte[] cipherText = cipher0.doFinal(plainText);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment