I have been trying to get the cardEncrypted in android java
public static PublicKey getPublicKey(final BigInteger modulus, final BigInteger exponent) { try { final KeyFactory factory = KeyFactory.getInstance("RSA"); final PublicKey publicKey = factory.generatePublic(new RSAPublicKeySpec(modulus, exponent)); return publicKey; } catch (GeneralSecurityException e) { return null; } } public static String encryptPAN(final String prefix, final String pan, PublicKey publicKey) { byte[] input = String.format("%s%s", prefix, pan).getBytes(); try { Cipher cipher = Cipher.getInstance("RSA/None/OAEPWithSHA1AndMGF1Padding"); cipher.init(Cipher.ENCRYPT_MODE, publicKey, new SecureRandom()); byte[] cipherText = cipher.doFinal(input); return Base64.encodeToString(cipherText, Base64.DEFAULT); } catch (GeneralSecurityException ignore) { return null; } }
here is the code
I am getting
{ "paymentId": "6KMQGW15R5N44", "result": "DECLINED", "failureMessage": "RE0528 - EncrptBlock is invalid|" }