Skip to content

Commit

Permalink
Decoded sessionKey with base64
Browse files Browse the repository at this point in the history
  • Loading branch information
RiccardoGiuliani committed Feb 12, 2024
1 parent 27d9878 commit 8099ab0
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.security.*;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.RSAPublicKeySpec;
Expand Down Expand Up @@ -38,7 +37,7 @@ public String encryptSessionKeyForIdpay(PublicKeyIDPay publicKeyIDPay, String se
Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding");
cipher.init(Cipher.ENCRYPT_MODE, rsaPublicKey);

byte[] sessionKeyBytes = sessionKey.getBytes(StandardCharsets.UTF_8);
byte[] sessionKeyBytes = Base64.getDecoder().decode(sessionKey);
byte[] encryptedSessionKeyBytes = cipher.doFinal(sessionKeyBytes);

// encryptedSessionKeyBytes contains encrypted session key
Expand Down

0 comments on commit 8099ab0

Please sign in to comment.