Skip to content

Instantly share code, notes, and snippets.

@sparse91
Created July 31, 2019 06:47
Show Gist options
  • Save sparse91/c85885749eba6bdc398d04fcd33ba3c3 to your computer and use it in GitHub Desktop.
Save sparse91/c85885749eba6bdc398d04fcd33ba3c3 to your computer and use it in GitHub Desktop.
شیوه رمز کردن اطلاعات درگاه پرداخت بانکی سداد در جاوا - Sadad Payment Gateway encryption method In Java
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