TsgcWSAPIKeyManagerMethods › ExportKeys

ExportKeys Method

Stream-based export of keys and audit log.

Syntax

procedure ExportKeys(aStream: TStream);

Parameters

NameTypeDescription
aStreamTStreamDestination stream; written sequentially from the current Position. Any TStream descendant works (TFileStream, TMemoryStream, HTTP response streams, custom streams for database or cloud storage).

Remarks

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.

Example

// 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;

Back to Methods