Skip to content

Instantly share code, notes, and snippets.

View newarifrh's full-sized avatar
:octocat:
Working from home

Arif Rahman Hakim newarifrh

:octocat:
Working from home
View GitHub Profile
@kevinjam
kevinjam / Decrypt.java
Last active September 7, 2022 07:25
RSA Encrypt in PHP and Decrypt in Java or Kotlin
public class DecryptKey {
//before you proceed, you need to ensure your public key is PKCS8 since that is what can be read natively in java.
//If your key begins with-----BEGIN CERTIFICATE-----,
// the it is ssleay and you need to convert it using the openssl command below
//openssl pkcs8 -topk8 -inform pem -in public.key -outform pem -nocrypt -out pkcs8-public-key.pem
//TODO You can you phpsecLib lib but it doesn't support some Library
//opnssl work fine
final private static String RSA_PRIVATE_KEY =
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzTrKt2Y7HqQpt8w379Sl