fork download
  1. import java.io.*;
  2. import java.security.*;
  3. import java.util.*;
  4. import javax.crypto.*;
  5. import javax.crypto.spec.*;
  6.  
  7.  
  8. public class myAESIV {
  9.  
  10. private static SecretKeySpec mykey;
  11. private static byte[] cipherkey;
  12.  
  13. public static String myencryption(String string1, String mysecretkey)
  14. {
  15. try
  16. {
  17. byte[] IV;
  18. setencryptionkey(mysecretkey);
  19. Cipher cipher = Cipher.getInstance("AES");
  20. cipher.init(Cipher.ENCRYPT_MODE, mykey);
  21. IV = cipherkey;
  22. String x = Base64.getEncoder().encodeToString(cipher.doFinal(string1.getBytes("UTF-8")));
  23. return x;
  24. }
  25. catch (Exception e){}
  26. return null;
  27. }
  28.  
  29. public static void setencryptionkey(String myKey)
  30. {
  31. MessageDigest securehash = null;
  32. try {
  33. cipherkey = myKey.getBytes("UTF-8");
  34. securehash = MessageDigest.getInstance("SHA-1");
  35. cipherkey = securehash.digest(cipherkey);
  36. cipherkey = Arrays.copyOf(cipherkey, 16);
  37. mykey = new SecretKeySpec(cipherkey, "AES");
  38. }
  39. catch (Exception e) {}
  40. }
  41. }
  42.  
  43.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:8: error: class myAESIV is public, should be declared in a file named myAESIV.java
public class myAESIV {
       ^
1 error
stdout
Standard output is empty