Created
July 31, 2019 06:47
-
-
Save sparse91/c85885749eba6bdc398d04fcd33ba3c3 to your computer and use it in GitHub Desktop.
شیوه رمز کردن اطلاعات درگاه پرداخت بانکی سداد در جاوا - Sadad Payment Gateway encryption method In Java
This file contains hidden or 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
private String signData(final String text) { | |
byte[] terminalKey = Base64.getDecoder().decode("__TERMINAL_KEY__")); | |
var secretKeySpec = new SecretKeySpec(terminalKey, "DESede"); | |
try { | |
var cipher = Cipher.getInstance("DESede"); | |
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec); | |
byte[] encryptedText = cipher.doFinal(text.getBytes()); | |
var encryptedTextString = Base64.getEncoder().encodeToString(encryptedText); | |
return encryptedTextString; | |
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | IllegalBlockSizeException | | |
BadPaddingException e) { | |
throw new RuntimeException(e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment