I have a private key as well as an ethereum public address. I want to encrypt a payload using a user public ethereum address and then give it to that user and then he can decrypt it using his private key. Or i can encrypt it using user public key and he can decrypt it using his private key
I have this public and private keys
const givenPrivateKey='c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3';
const givenEthAddress = '0x627306090abab3a6e1400e9345bc60c78a8bef57';
i tried it via
const encrypted = crypto.publicEncrypt(publkey, data);
but it failed, i thing it takes .pem file as a public key.
is there anyway to encrypt it via public key string like this?
const pub key='af80b90d25145da28c583359beb47b21796b2fe1a23c1511e443e7a64dfdb27d7434c380f0aa4c500e220aa1a9d068514b1ff4d5019e624e7ba1efe82b340a59'
Thanks alot!