Skip to Content

Encrypt single field with private key in KeyStore and encode base64

Jan 09 at 12:30 PM


avatar image

Hello Experts,

I have a requirement to encrypt single field in the payload with Certificate and private key stored in NWA keystore with SHA256withRSA and encode it base64. I had referred below links

Signature signature = Signature.getInstance("SHA256withRSA"); signature.initSign((PrivateKey) String.getKey(alias, password.toCharArray())); signature.update(plaintext.getBytes("UTF-8"));

byte[] rsa_text= signature.sign();

I'm unable to get it for single field. Can you please provide code snippet for single key.



10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Muni M Jan 10 at 11:07 AM

You need public key for encryption. wikipedia

check this below using some randon key

check this reply on how to access the keystore.

if you can create key successfully, then you should be able to perform encryption. search you will find code.

10 |10000 characters needed characters left characters exceeded