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 java.nio.charset.StandardCharsets;
  7. import javax.crypto.Cipher;
  8. import javax.crypto.spec.IvParameterSpec;
  9. import javax.crypto.spec.SecretKeySpec;
  10. import java.util.Base64;
  11.  
  12. /* Name of the class has to be "Main" only if the class is public. */
  13. class Ideone
  14. {
  15.  
  16. public static String decrypt(String str) {
  17. SecretKeySpec secretKeySpec = new SecretKeySpec(new byte[]{45, 82, 35, 42, 114, 69, 104, 97, 83, 65, 112, 53, 55, 68, 97, 115}, "AES");
  18. try {
  19. Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding");
  20. byte[] decode = Base64.getDecoder().decode(str.getBytes(StandardCharsets.UTF_8));
  21. byte[] copyOfRange = Arrays.copyOfRange(decode, 0, 16);
  22. byte[] copyOfRange2 = Arrays.copyOfRange(decode, 16, decode.length);
  23. cipher.init(2, secretKeySpec, new IvParameterSpec(copyOfRange));
  24. return new String(cipher.doFinal(copyOfRange2), StandardCharsets.UTF_8);
  25. } catch (Exception unused) {
  26. return str;
  27. }
  28. }
  29.  
  30.  
  31. public static void main (String[] args) throws java.lang.Exception
  32. {
  33. // your code goes here
  34. String output = decrypt("4BYlrCNPJZncIACG4mayRywzFfnQhMVCWp4dgGhmF0eAQ7trwjAB1fNz210nuxnGvk4Ctaqlv7TsaIoIbw+lSGPwOxBGGb4Yi6LsQ3mG7TlnT4CSKDKs7sMTImSh4cI9Vuo8i/yXxEIozZB2KhhbsnLrWSxahh4FIMCb7TDDGHo=");
  35. System.out.println("Decoded: " + output);
  36. }
  37. }
Success #stdin #stdout 0.3s 60952KB
stdin
Standard input is empty
stdout
Decoded: 4BYlrCNPJZncIACG4mayRywzFfnQhMVCWp4dgGhmF0eAQ7trwjAB1fNz210nuxnGvk4Ctaqlv7TsaIoIbw+lSGPwOxBGGb4Yi6LsQ3mG7TlnT4CSKDKs7sMTImSh4cI9Vuo8i/yXxEIozZB2KhhbsnLrWSxahh4FIMCb7TDDGHo=