-
Notifications
You must be signed in to change notification settings - Fork 778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RSA/ECB/PKCS1Padding #407
Comments
You can find examples on how to do RSA-based encryption here: https://github.com/digitalbazaar/forge#rsa Specifically, you can do RSA public key encryption with PKCS1 padding like this: // load public key from PEM-formatted string
var pem = '-----BEGIN PUBLIC KEY...';
var publicKey = forge.pki.publicKeyFromPem(pem);
// convert string to UTF-8 encoded bytes
var buffer = forge.util.createBuffer('Something to encrypt', 'utf8');
var bytes = buffer.getBytes();
// encrypt data with a public key using RSAES PKCS#1 v1.5
var encrypted = publicKey.encrypt(bytes, 'RSAES-PKCS1-V1_5');
// base64-encode encrypted data to send to server
var b64Encoded = forge.util.encode64(encrypted); |
you encrypt data with random key in ECB then you encrypt the key with rsa using pkcs1.5 .. RSA doesn't encrypt ECB symmetric keys do that Kind Regards,
|
Closing out as resolved, feel free to reopen if necessary. |
it's work for me, thanks. |
Hi
I am new to forge and I am coming from JAVA. Can you please show me how to encrypt using RSA with ECB mode and PKCS1 Padding.
please help am stuck now
thanks
The text was updated successfully, but these errors were encountered: