Dart
Dart
Get the JWE Protected Header
See more JSON Web Encryption (JWE) Examples
Demonstrates Jwe.GetProtectedHeader, which copies the decoded shared JWE protected header into a JsonObject.
Background. Only the protected header is returned; it is not merged with the shared unprotected header or any per-recipient header.
Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
final jwe = CkJwe();
// Load the JWE.
final jweCompact = 'eyJhbGciOiJBMjU2S1ciLCJlbmMiOiJBMjU2R0NNIn0.<...>.<iv>.<ciphertext>.<tag>';
try {
jwe.loadJwe(jweCompact);
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
// Copy the decoded shared JWE protected header into a JsonObject. Only the protected header is
// returned; it is not merged with the unprotected or per-recipient headers.
final json = CkJsonObject();
try {
jwe.getProtectedHeader(json);
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
json.emitCompact = false;
print(json.emit());
}