thieumao

Base64

Dec 17th, 2013
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.25 KB | None | 0 0
  1. package com.kma.ctf2;
  2. import java.security.MessageDigest;
  3. import javax.crypto.Cipher;
  4. import javax.crypto.spec.SecretKeySpec;
  5. import sun.misc.BASE64Decoder;
  6. public class Decode1 {
  7.     public String returnFlag() {
  8.         try {
  9.             MessageDigest localMessageDigest = MessageDigest.getInstance("SHA");
  10.             localMessageDigest.update("KMA_fag_not_here".getBytes());
  11.             SecretKeySpec localSecretKeySpec = new SecretKeySpec(localMessageDigest.digest(), 0, 16, "AES");
  12.             Cipher localCipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
  13. //            byte[] arrayOfByte = Base64.decode("rMto79APL5CFQ9PU6iSP6e2tbxRJ6Xv0s5znSnYneog=", 0);
  14.             BASE64Decoder decoder = new BASE64Decoder();
  15.             byte[] arrayOfByte = decoder.decodeBuffer("rMto79APL5CFQ9PU6iSP6e2tbxRJ6Xv0s5znSnYneog=");
  16.             //
  17.             localCipher.init(2, localSecretKeySpec);
  18.             String str = new String(localCipher.doFinal(arrayOfByte));
  19.             return str;
  20.         } catch (Exception localException) {
  21.             localException.printStackTrace();
  22.         }
  23.         return null;
  24.     }
  25.     public static void main(String[] args) {
  26.         Decode1 dc = new Decode1();
  27.         System.out.println("" + dc.returnFlag());
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment