You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import*asjosefrom"jose";constfirstRecipientKeyPair=awaitjose.generateKeyPair("RSA-OAEP-256");constsecondRecipientKeyPair=awaitjose.generateKeyPair("ECDH-ES+A256KW");constthirdRecipientSecret=awaitjose.generateSecret("A256GCMKW");constencoder=newTextEncoder();constplaintext=encoder.encode("It’s a dangerous business, Frodo, going out your door.");constadditionalAuthenticatedData=encoder.encode("The Fellowship of the Ring");constenc=newjose.GeneralEncrypt(plaintext).setAdditionalAuthenticatedData(additionalAuthenticatedData).setProtectedHeader({enc: "A256GCM"});enc.addRecipient(firstRecipientKeyPair.publicKey).setUnprotectedHeader({alg: "RSA-OAEP-256"});enc.addRecipient(secondRecipientKeyPair.publicKey).setUnprotectedHeader({alg: "ECDH-ES+A256KW"});enc.addRecipient(thirdRecipientSecret).setUnprotectedHeader({alg: "A256GCMKW"});constjwe=awaitenc.encrypt();console.log(JSON.stringify(jwe,null,4));for(constrecipientKeyof[firstRecipientKeyPair.privateKey,secondRecipientKeyPair.privateKey,thirdRecipientSecret,]){awaitjose.generalDecrypt(jwe,recipientKey);}
This discussion was created from the release v4.2.0.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Features
example
UsageThis discussion was created from the release v4.2.0.
Beta Was this translation helpful? Give feedback.
All reactions