sealMagicNumber function

SealHeader sealMagicNumber(
  1. Pointer<Uint8> raw,
  2. int length
)

Parse a serialized byte array and return the SealHeader object.

When a serialized byte array is loaded, the header is checked for the SEAL magic number. If the magic number is not found, an exception is thrown.

Implementation

SealHeader sealMagicNumber(Pointer<Uint8> raw, int length) {
  // Cast raw pointer to SealHeader
  final header = raw.cast<SealHeader>().ref;
  // Check SEAL Magic Number, A1 (161) 5E (94)
  if (header.sealMagic[0] != 94 || header.sealMagic[1] != 161) {
    throw Exception('Invalid SEAL Magic Number');
  }
  return header;
}