Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MainActivity extends AppCompatActivity {
- private String CLIENT_KEY = "&eF2W7@Eu~5wV+Bwm9*EA*FV";
- private String CLIENT = "STANDARD-BANK";
- TextView o, e, d;
- int ctLength;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- try {
- Log.d("INIT TO: ", CLIENT);
- Log.d("HMAC: ", "DOCUMENTSCANN - DEV key");
- byte[] documentScannKey = crypto("5SH6UAPW-6SZQU2D3-A4KWUU5A-BQANA7W5-QIOKVNXP-EMFGQO3P-SUKRI2KS-OZFL6MIX");
- Log.d("Encripted: ", documentScannKey.toString());
- Log.d("Decripted: ", decrypt(documentScannKey));
- Log.d("FINISH", "********************");
- Log.d("HMAC: ", "LIVENESS - DEV key");
- byte[] livenessKey = crypto("c1228826702b16d450775cad737e5189647aa774");
- Log.d("Encripted: ", livenessKey.toString());
- Log.d("Decripted: ", decrypt(livenessKey));
- Log.d("FINISH", "********************");
- Log.d("HMAC: ", "SUBMIT_DATA - DEV API key");
- byte[] apiKey = crypto("E9742373-BA5B-455D-90CB-8385991FC266");
- Log.d("Encripted: ", apiKey.toString());
- Log.d("Decripted: ", decrypt(apiKey));
- Log.d("FINISH", "********************");
- Log.d("HMAC: ", "SUBMIT_DATA - DEV SECRET key");
- byte[] secretKey = crypto("0B92DBFC-BC12-464B-B48C-EE201D18C3AA");
- Log.d("Encripted: ", secretKey.toString());
- Log.d("Decripted: ", decrypt(secretKey));
- Log.d("FINISH", "********************");
- Log.d("HMAC: ", "SUBMIT_DATA - STA API key");
- byte[] apiKeySTA = crypto("E9742373-BA5B-455D-90CB-8385991FC266");
- Log.d("Encripted: ", apiKeySTA.toString());
- Log.d("Decripted: ", decrypt(apiKeySTA));
- Log.d("FINISH", "********************");
- Log.d("HMAC: ", "SUBMIT_DATA - STA SECRET key");
- byte[] secretKeySTA = crypto("0B92DBFC-BC12-464B-B48C-EE201D18C3AA");
- Log.d("Encripted: ", secretKeySTA.toString());
- Log.d("Decripted: ", decrypt(secretKeySTA));
- Log.d("FINISH", "********************");
- Log.d("HMAC: ", "SUBMIT_DATA - PROD API key");
- byte[] apiKeyPROD = crypto("5A73D95C-C760-4606-9876-AA11958909CE");
- Log.d("Encripted: ", apiKeyPROD.toString());
- Log.d("Decripted: ", decrypt(apiKeyPROD));
- Log.d("FINISH", "********************");
- Log.d("HMAC: ", "SUBMIT_DATA - PROD SECRET key");
- byte[] secretKeyPROD = crypto("F4E1B92A-0B51-423A-A84F-140B0D3339DE");
- Log.d("Encripted: ", secretKeyPROD.toString());
- Log.d("Decripted: ", decrypt(secretKeyPROD));
- Log.d("FINISH", "********************");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public byte[] crypto(String data) throws Exception {
- byte[] input = data.getBytes();
- // byte[] keyBytes = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04,
- // 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
- // 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14,
- // 0x15, 0x16, 0x17 };
- byte[] keyBytes = CLIENT_KEY.getBytes();
- SecretKeySpec key = new SecretKeySpec(keyBytes, "AES");
- Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding", "BC");
- //System.out.println(new String(input));
- //o.setText("Original: " + new String(input));
- // encryption pass
- cipher.init(Cipher.ENCRYPT_MODE, key);
- byte[] cipherText = new byte[cipher.getOutputSize(input.length)];
- ctLength = cipher.update(input, 0, input.length, cipherText, 0);
- ctLength += cipher.doFinal(cipherText, ctLength);
- //System.out.println(new String(cipherText));
- //e.setText("Encrypted: " + new String(cipherText));
- System.out.println("ENCRYPT: " + ctLength);
- return cipherText;
- }
- public String decrypt(byte[] data) throws Exception {
- byte[] keyBytes = CLIENT_KEY.getBytes();
- SecretKeySpec key = new SecretKeySpec(keyBytes, "AES");
- Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding", "BC");
- cipher.init(Cipher.DECRYPT_MODE, key);
- byte[] plainText = new byte[cipher.getOutputSize(ctLength)];
- int ptLength = cipher.update(data, 0, ctLength, plainText, 0);
- ptLength += cipher.doFinal(plainText, ptLength);
- //System.out.println(new String(plainText));
- //d.setText("Decrypted: " + new String(plainText));
- System.out.println("DECRYPT " + ptLength);
- return new String(plainText);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment