TsgcWSAPIKeyManager › Methods › ExportKeys
Stream-based export of keys and audit log.
procedure ExportKeys(aStream: TStream);
| Name | Type | Description |
|---|---|---|
aStream | TStream | Destination stream; written sequentially from the current Position. Any TStream descendant works (TFileStream, TMemoryStream, HTTP response streams, custom streams for database or cloud storage). |
Stream-based counterpart of SaveToFile. Writes exactly the same binary payload (versioned header + hashed keys + audit entries, optionally encrypted with Storage.EncryptionKey) into the supplied stream. Use it to replicate the key store to another process, push it into a database BLOB column, or stream it to a disaster-recovery bucket — you are not limited to the local file system. Plaintext keys are never emitted, only their hashes.
// Push the key store into an HTTP response for replication to a standby
var
oStream: TMemoryStream;
begin
oStream := TMemoryStream.Create;
try
sgcWSAPIKeyManager1.ExportKeys(oStream);
oStream.Position := 0;
Response.ContentStream := oStream;
Response.SendResponse;
finally
sgcFree(oStream);
end;
end;