Created
February 14, 2017 12:32
-
-
Save CreateRemoteThread/e443b152123a0828e896fae7aef7e5f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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