fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import javax.crypto.Cipher;
  7. import javax.crypto.spec.SecretKeySpec;
  8. import java.util.Base64;
  9.  
  10.  
  11. /* Name of the class has to be "Main" only if the class is public. */
  12. class Ideone
  13. {
  14. public static void main (String[] args) throws java.lang.Exception
  15. {
  16. // your code goes here
  17. }
  18.  
  19. protected String decryptFlag(byte[] key, String encrypted) {
  20. SecretKeySpec keySpec = new SecretKeySpec(key, "AES");
  21. Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING");
  22. cipher.init(2, keySpec);
  23. return new String(cipher.doFinal(Base64.getDecoder().decode(encrypted)));
  24. }
  25. }
Compilation error #stdin compilation error #stdout 0.04s 4386816KB
stdin
Standard input is empty
compilation info
Main.java:21: error: unreported exception NoSuchAlgorithmException; must be caught or declared to be thrown
        Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING");
                                          ^
Main.java:22: error: unreported exception InvalidKeyException; must be caught or declared to be thrown
        cipher.init(2, keySpec);
                   ^
Main.java:23: error: unreported exception IllegalBlockSizeException; must be caught or declared to be thrown
        return new String(cipher.doFinal(Base64.getDecoder().decode(encrypted)));
                                        ^
3 errors
stdout
Standard output is empty