Skip to content

Instantly share code, notes, and snippets.

@CreateRemoteThread
Created February 14, 2017 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CreateRemoteThread/e443b152123a0828e896fae7aef7e5f7 to your computer and use it in GitHub Desktop.
Save CreateRemoteThread/e443b152123a0828e896fae7aef7e5f7 to your computer and use it in GitHub Desktop.
// rename as HelloWorld.java :)
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.SecretKeySpec;
import sun.misc.BASE64Decoder;
public class HelloWorld{
public static void main(String[] args) throws Exception
{
String SECRET = "Bi528nDlNBcX9BcCC+ZqGQo1Oz01+GOWSmvxRj7jg1g=";
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
byte[] salt = "SampleSalt".getBytes();
String pin = "7498";
SecretKeySpec key = new SecretKeySpec(SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1").generateSecret(new PBEKeySpec(pin.toCharArray(), salt, 1000, 128)).getEncoded(), "AES");
cipher.init(2,key);
BASE64Decoder decoder = new BASE64Decoder();
System.out.println(new String(cipher.doFinal(decoder.decodeBuffer(SECRET)),"UTF-8"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment