https://github.com/cisco/node-jose it's my code example:
let keystore1;
let keystore2;
keystore1 = JWK.createKeyStore();
keystore2 = JWK.createKeyStore();
const input = { message: { text: 'Привет!' } };
const priv1 = await keystore1.generate('EC', 'P-256', {
kid: '1gBdaS-G8RLax2qgObTD94w',
key_ops:["sign", "decrypt", "unwrap"]
});
const priv2 = await keystore2.generate('EC', 'P-256', {
kid: '2gBdaS-G8RLax2qgObTD94v',
key_ops:["sign", "decrypt", "unwrap"]
});
const pub1 = await JWK.asKey(priv1.toJSON());
const pub2 = await JWK.asKey(priv2.toJSON());
const encrypted = await JWE.createEncrypt(
{
format: 'compact',
fields: {
alg: 'ECDH-ES',
enc: 'A128CBC-HS256',
cty: 'json', // replace with JWT if you're encrypting a JWT...
},
},
{
key: pub2,
}
)
.update(JSON.stringify(input))
.final();
console.log('encrypted', encrypted);
const decrypted = await JWE.createDecrypt(priv2).decrypt(encrypted);
console.log('decrypted', JSON.parse(decrypted.payload.toString()));
// simulate only having access to the public key, usually this is your starting point as you only have access to the public components if you're encrypting a message for someone else.
With latin - decryption ok! How to decrypte with cyrillic, please help me.