Skip to content

Commit e4e5b80

Browse files
committed
Tweak example
1 parent 40b1f74 commit e4e5b80

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

examples/jwe_encrypt_json_example_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ func Example_jwe_encrypt_json() {
2929
}
3030

3131
const payload = `Lorem ipsum`
32-
encrypted, err := jwe.Encrypt([]byte(payload), jwe.WithJSON(), jwe.WithKey(jwa.RSA_OAEP(), pubkey))
32+
encrypted, err := jwe.Encrypt(
33+
[]byte(payload),
34+
jwe.WithJSON(), // Toggle JSON serialization. Because there's only one key (recipient), this will produce Flattened JSON serialization
35+
jwe.WithLegacyHeaderMerging(false), // Disable legacy header merging
36+
jwe.WithKey(jwa.RSA_OAEP(), pubkey), // Public key for encryption
37+
)
3338
if err != nil {
3439
fmt.Printf("failed to encrypt payload: %s\n", err)
3540
return

0 commit comments

Comments
 (0)