ApiKeyGenerator
AgentPrism.Core.dllA helper that produces a raw API key value and its hash.
public static class ApiKeyGeneratorInheritance
Section titled “Inheritance”Inherited Members
Section titled “Inherited Members”object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”Format: ap_{tenant-prefix}_{32-byte-base64url}
The prefix exists only
for READABILITY; it is not used for authentication — lookup always goes
through the hash produced by ApiKeyGenerator.ComputeHash.
The hash algorithm is SHA-256, not Argon2. The key is a RANDOM 32-byte value, not a user password; a dictionary attack does not apply, and a slow hash would only add latency to every request.
Methods
Section titled “Methods”ComputeHash(string)
Section titled “ ComputeHash(string)”Computes the SHA-256 hash of a raw key value.
public static byte[] ComputeHash(string plaintextKey)Parameters
Section titled “Parameters”plaintextKey string
The raw value.
Returns
Section titled “Returns”byte[]
The 32-byte hash.
Exceptions
Section titled “Exceptions”plaintextKey is empty.
Generate(string)
Section titled “ Generate(string)”Generates a new raw key.
public static GeneratedApiKey Generate(string tenantId)Parameters
Section titled “Parameters”tenantId string
The tenant the key attaches to (read only for the prefix).
Returns
Section titled “Returns”The raw value, its hash, and a display prefix.
Exceptions
Section titled “Exceptions”tenantId is empty.