Sample code for 30+ languages & platforms
Delphi DLL Requires Chilkat v11.6.0+

Azure Key Vault: RSA-OAEP-256 Wrap and Unwrap an AES Key

See more Azure Key Vault Examples

Requires Chilkat 11.6.0 or later. Keep qa_data/azure/keyvault.json and token/PFX files private, outside web content and source control, with access restricted to the application identity. Use placeholders replaced by your configuration, never commit credentials. Create output directories before running file-writing examples. These examples target Azure public-cloud vaults, not Managed HSM or sovereign-cloud endpoints.

Uses HTTPS and Key Vault data-plane API 2026-04-01. Configure vault_name and first run the client-credentials token example. It writes access_token and an expires_at UTC timestamp to qa_data/tokens/azureKeyVaultToken.json. Each request checks expiration; refresh is explicit. The sample stops on errors and does not retry. Production callers should handle 429/Retry-After and transient failures with bounded backoff, and reconcile uncertain writes. Redirects are disabled.

Set key_name and object_version for a compatible RSA key. Requires keys/get and keys/wrapKey plus keys/unwrapKey. Uses the same pinned key version in both operations and checks returned kid. Never prints plaintext or key bytes. Generates a fresh 32-byte AES key, wraps it, then unwraps it for a round-trip check. An envelope-encryption application must also store the exact versioned kid, algorithm, wrapped key, nonce and authentication tag alongside ciphertext; rotating a key does not rewrap old data.

Microsoft reference

Chilkat Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
stringCompare: HCkStringBuilder;
config: HCkJsonObject;
stringMatch1: Boolean;
validate1: HCkStringBuilder;
alphabet1: HCkStringBuilder;
charIndex1: Integer;
vaultName: HCkStringBuilder;
letters: HCkStringBuilder;
origin: HCkStringBuilder;
http: HCkHttp;
request: HCkHttpRequest;
response: HCkHttpResponse;
result: HCkJsonObject;
token: HCkJsonObject;
stringMatch2: Boolean;
stringMatch3: Boolean;
expires: HCkDateTime;
now: HCkDateTime;
stringMatch4: Boolean;
validate20: HCkStringBuilder;
alphabet20: HCkStringBuilder;
charIndex20: Integer;
resourceBase: HCkStringBuilder;
stringMatch5: Boolean;
validate21: HCkStringBuilder;
alphabet21: HCkStringBuilder;
charIndex21: Integer;
resourceId: HCkStringBuilder;
getUrl: HCkStringBuilder;
stringMatch6: Boolean;
stringMatch7: Boolean;
jwk: HCkJsonObject;
publicKey: HCkPublicKey;
stringMatch8: Boolean;
stringMatch9: Boolean;
plaintext: HCkBinData;
random: HCkPrng;
aesKey: PWideChar;
body: HCkJsonObject;
firstUrl: HCkStringBuilder;
stringMatch10: Boolean;
stringMatch11: Boolean;
stringMatch12: Boolean;
validate35: HCkStringBuilder;
alphabet35: HCkStringBuilder;
charIndex35: Integer;
ciphertext: PWideChar;
secondUrl: HCkStringBuilder;
stringMatch13: Boolean;
stringMatch14: Boolean;
stringMatch15: Boolean;
recovered: HCkBinData;
stringMatch16: Boolean;

begin
success := False;

stringCompare := CkStringBuilder_Create();
//  Assumes Chilkat is unlocked. See Global Unlock Sample.
//  Keep this configuration private, outside public web content and source control.
config := CkJsonObject_Create();
CkJsonObject_putStrict(config,True);
success := CkJsonObject_LoadFile(config,'qa_data/azure/keyvault.json');
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not load private Key Vault configuration.');
    Exit;
  end;
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(config,'vault_name'));
stringMatch1 := CkStringBuilder_ContentsEqual(stringCompare,'',True);
if ((CkJsonObject_JsonTypeOf(config,'vault_name') <> 1) or (stringMatch1 = True)) then
  begin
    Memo1.Lines.Add('Missing or invalid vault_name.');
    Exit;
  end;
validate1 := CkStringBuilder_Create();
alphabet1 := CkStringBuilder_Create();
success := CkStringBuilder_Append(validate1,CkJsonObject__stringOf(config,'vault_name'));
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not validate vault_name.');
    Exit;
  end;
success := CkStringBuilder_Append(alphabet1,'abcdefghijklmnopqrstuvwxyz0123456789-');
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not initialize validation.');
    Exit;
  end;
if ((CkStringBuilder_getLength(validate1) < 3) or (CkStringBuilder_getLength(validate1) > 24)) then
  begin
    Memo1.Lines.Add('Invalid vault_name length.');
    Exit;
  end;
charIndex1 := 0;
while (charIndex1 < CkStringBuilder_getLength(validate1)) do
  begin
    if (CkStringBuilder_Contains(alphabet1,CkStringBuilder__getRange(validate1,charIndex1,1,False),True) <> True) then
      begin
        Memo1.Lines.Add('Invalid character in vault_name.');
        Exit;
      end;
    charIndex1 := charIndex1 + 1;
  end;

vaultName := CkStringBuilder_Create();
CkStringBuilder_Append(vaultName,CkJsonObject__stringOf(config,'vault_name'));
letters := CkStringBuilder_Create();
CkStringBuilder_Append(letters,'abcdefghijklmnopqrstuvwxyz');
if ((CkStringBuilder_Contains(letters,CkStringBuilder__getRange(vaultName,0,1,False),True) <> True) or (CkStringBuilder_EndsWith(vaultName,'-',True) = True) or (CkStringBuilder_Contains(vaultName,'--',True) = True)) then
  begin
    Memo1.Lines.Add('Invalid vault_name.');
    Exit;
  end;
origin := CkStringBuilder_Create();
success := CkStringBuilder_Append(origin,'https://');
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not construct URL or identifier.');
    Exit;
  end;
success := CkStringBuilder_Append(origin,CkJsonObject__stringOf(config,'vault_name'));
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not construct URL or identifier.');
    Exit;
  end;
success := CkStringBuilder_Append(origin,'.vault.azure.net');
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not construct URL or identifier.');
    Exit;
  end;
http := CkHttp_Create();
CkHttp_putRequireSslCertVerify(http,True);
CkHttp_putFollowRedirects(http,False);
CkHttp_putConnectTimeout(http,20);
CkHttp_putReadTimeout(http,60);
CkHttp_putVerboseLogging(http,False);
request := CkHttpRequest_Create();
CkHttpRequest_putHttpVerb(request,'GET');
response := CkHttpResponse_Create();
result := CkJsonObject_Create();
CkJsonObject_putStrict(result,True);
//  First run Get a Key Vault access token.
token := CkJsonObject_Create();
CkJsonObject_putStrict(token,True);
success := CkJsonObject_LoadFile(token,'qa_data/tokens/azureKeyVaultToken.json');
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not read the private token file.');
    Exit;
  end;
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(token,'access_token'));
stringMatch2 := CkStringBuilder_ContentsEqual(stringCompare,'',True);
if ((CkJsonObject_JsonTypeOf(token,'access_token') <> 1) or (stringMatch2 = True)) then
  begin
    Memo1.Lines.Add('Missing or invalid access_token.');
    Exit;
  end;
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(token,'expires_at'));
stringMatch3 := CkStringBuilder_ContentsEqual(stringCompare,'',True);
if ((CkJsonObject_JsonTypeOf(token,'expires_at') <> 1) or (stringMatch3 = True)) then
  begin
    Memo1.Lines.Add('Missing or invalid expires_at.');
    Exit;
  end;
expires := CkDateTime_Create();
now := CkDateTime_Create();
success := CkDateTime_SetFromTimestamp(expires,CkJsonObject__stringOf(token,'expires_at'));
if (success <> True) then
  begin
    Memo1.Lines.Add('Invalid token expiration.');
    Exit;
  end;
CkHttp_putAuthToken(http,CkJsonObject__stringOf(token,'access_token'));
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(config,'key_name'));
stringMatch4 := CkStringBuilder_ContentsEqual(stringCompare,'',True);
if ((CkJsonObject_JsonTypeOf(config,'key_name') <> 1) or (stringMatch4 = True)) then
  begin
    Memo1.Lines.Add('Missing or invalid key_name.');
    Exit;
  end;
validate20 := CkStringBuilder_Create();
alphabet20 := CkStringBuilder_Create();
success := CkStringBuilder_Append(validate20,CkJsonObject__stringOf(config,'key_name'));
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not validate key_name.');
    Exit;
  end;
success := CkStringBuilder_Append(alphabet20,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-');
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not initialize validation.');
    Exit;
  end;
if ((CkStringBuilder_getLength(validate20) < 1) or (CkStringBuilder_getLength(validate20) > 127)) then
  begin
    Memo1.Lines.Add('Invalid key_name length.');
    Exit;
  end;
charIndex20 := 0;
while (charIndex20 < CkStringBuilder_getLength(validate20)) do
  begin
    if (CkStringBuilder_Contains(alphabet20,CkStringBuilder__getRange(validate20,charIndex20,1,False),True) <> True) then
      begin
        Memo1.Lines.Add('Invalid character in key_name.');
        Exit;
      end;
    charIndex20 := charIndex20 + 1;
  end;

resourceBase := CkStringBuilder_Create();
success := CkStringBuilder_Append(resourceBase,CkStringBuilder__getAsString(origin));
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not construct URL or identifier.');
    Exit;
  end;
success := CkStringBuilder_Append(resourceBase,'/keys/');
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not construct URL or identifier.');
    Exit;
  end;
success := CkStringBuilder_Append(resourceBase,CkJsonObject__stringOf(config,'key_name'));
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not construct URL or identifier.');
    Exit;
  end;
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(config,'object_version'));
stringMatch5 := CkStringBuilder_ContentsEqual(stringCompare,'',True);
if ((CkJsonObject_JsonTypeOf(config,'object_version') <> 1) or (stringMatch5 = True)) then
  begin
    Memo1.Lines.Add('Missing or invalid object_version.');
    Exit;
  end;
validate21 := CkStringBuilder_Create();
alphabet21 := CkStringBuilder_Create();
success := CkStringBuilder_Append(validate21,CkJsonObject__stringOf(config,'object_version'));
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not validate object_version.');
    Exit;
  end;
success := CkStringBuilder_Append(alphabet21,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-');
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not initialize validation.');
    Exit;
  end;
if ((CkStringBuilder_getLength(validate21) < 1) or (CkStringBuilder_getLength(validate21) > 127)) then
  begin
    Memo1.Lines.Add('Invalid object_version length.');
    Exit;
  end;
charIndex21 := 0;
while (charIndex21 < CkStringBuilder_getLength(validate21)) do
  begin
    if (CkStringBuilder_Contains(alphabet21,CkStringBuilder__getRange(validate21,charIndex21,1,False),True) <> True) then
      begin
        Memo1.Lines.Add('Invalid character in object_version.');
        Exit;
      end;
    charIndex21 := charIndex21 + 1;
  end;

resourceId := CkStringBuilder_Create();
success := CkStringBuilder_Append(resourceId,CkStringBuilder__getAsString(resourceBase));
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not construct URL or identifier.');
    Exit;
  end;
success := CkStringBuilder_Append(resourceId,'/');
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not construct URL or identifier.');
    Exit;
  end;
success := CkStringBuilder_Append(resourceId,CkJsonObject__stringOf(config,'object_version'));
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not construct URL or identifier.');
    Exit;
  end;
getUrl := CkStringBuilder_Create();
success := CkStringBuilder_Append(getUrl,CkStringBuilder__getAsString(resourceId));
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not construct URL or identifier.');
    Exit;
  end;
success := CkStringBuilder_Append(getUrl,'?api-version=2026-04-01');
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not construct URL or identifier.');
    Exit;
  end;
success := CkDateTime_SetFromCurrentSystemTime(now);
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not read current time.');
    Exit;
  end;
if (CkDateTime_DiffSeconds(expires,now) <= 60) then
  begin
    Memo1.Lines.Add('Token is expired or near expiration. Obtain a new token before continuing.');
    Exit;
  end;
CkHttpRequest_putHttpVerb(request,'GET');
success := CkHttp_HttpReq(http,CkStringBuilder__getAsString(getUrl),request,response);
if (success <> True) then
  begin
    Memo1.Lines.Add('Request did not complete; inspect diagnostics privately.');
    Exit;
  end;
if (CkHttpResponse_getStatusCode(response) <> 200) then
  begin
    Memo1.Lines.Add('Unexpected HTTP status; inspect request ID and diagnostics privately. Reconcile writes before retrying.');
    Exit;
  end;
success := CkJsonObject_Load(result,CkHttpResponse__bodyStr(response));
if (success <> True) then
  begin
    Memo1.Lines.Add('Invalid JSON response.');
    Exit;
  end;
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(result,'key.kid'));
stringMatch6 := CkStringBuilder_ContentsEqual(stringCompare,'',True);
if ((CkJsonObject_JsonTypeOf(result,'key.kid') <> 1) or (stringMatch6 = True)) then
  begin
    Memo1.Lines.Add('Missing or invalid key.kid.');
    Exit;
  end;
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(result,'key.kid'));
stringMatch7 := CkStringBuilder_ContentsEqual(stringCompare,CkStringBuilder__getAsString(resourceId),True);
if (stringMatch7 <> True) then
  begin
    Memo1.Lines.Add('Response identifier does not match the requested version.');
    Exit;
  end;
jwk := CkJsonObject_Create();
success := CkJsonObject_ObjectOf2(result,'key',jwk);
if (success <> True) then
  begin
    Memo1.Lines.Add('Missing key JWK.');
    Exit;
  end;
publicKey := CkPublicKey_Create();
success := CkPublicKey_LoadFromString(publicKey,CkJsonObject__emit(jwk));
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not load public JWK.');
    Exit;
  end;
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(jwk,'kty'));
stringMatch8 := CkStringBuilder_ContentsEqual(stringCompare,'RSA',True);
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(jwk,'kty'));
stringMatch9 := CkStringBuilder_ContentsEqual(stringCompare,'RSA-HSM',True);
if ((stringMatch8 <> True) and (stringMatch9 <> True)) then
  begin
    Memo1.Lines.Add('RSA-OAEP-256 requires RSA.');
    Exit;
  end;
plaintext := CkBinData_Create();
random := CkPrng_Create();
aesKey := CkPrng__genRandom(random,32,'base64url');
if (CkPrng_getLastMethodSuccess(random) <> True) then
  begin
    Memo1.Lines.Add('Could not generate a 256-bit AES key.');
    Exit;
  end;
success := CkBinData_AppendEncoded(plaintext,aesKey,'base64url');
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not load AES key.');
    Exit;
  end;
body := CkJsonObject_Create();
success := CkJsonObject_UpdateString(body,'alg','RSA-OAEP-256');
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not set alg.');
    Exit;
  end;
success := CkJsonObject_UpdateString(body,'value',CkBinData__getEncoded(plaintext,'base64url'));
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not set value.');
    Exit;
  end;
firstUrl := CkStringBuilder_Create();
success := CkStringBuilder_Append(firstUrl,CkStringBuilder__getAsString(resourceId));
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not construct URL or identifier.');
    Exit;
  end;
success := CkStringBuilder_Append(firstUrl,'/wrapkey?api-version=2026-04-01');
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not construct URL or identifier.');
    Exit;
  end;
success := CkDateTime_SetFromCurrentSystemTime(now);
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not read current time.');
    Exit;
  end;
if (CkDateTime_DiffSeconds(expires,now) <= 60) then
  begin
    Memo1.Lines.Add('Token is expired or near expiration. Obtain a new token before continuing.');
    Exit;
  end;
success := CkHttp_HttpJson(http,'POST',CkStringBuilder__getAsString(firstUrl),body,'application/json',response);
if (success <> True) then
  begin
    Memo1.Lines.Add('Request failed; reconcile uncertain writes before retrying.');
    Exit;
  end;
if (CkHttpResponse_getStatusCode(response) <> 200) then
  begin
    Memo1.Lines.Add('Unexpected HTTP status; inspect request ID and diagnostics privately. Reconcile writes before retrying.');
    Exit;
  end;
success := CkJsonObject_Load(result,CkHttpResponse__bodyStr(response));
if (success <> True) then
  begin
    Memo1.Lines.Add('Invalid JSON response.');
    Exit;
  end;
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(result,'kid'));
stringMatch10 := CkStringBuilder_ContentsEqual(stringCompare,'',True);
if ((CkJsonObject_JsonTypeOf(result,'kid') <> 1) or (stringMatch10 = True)) then
  begin
    Memo1.Lines.Add('Missing or invalid kid.');
    Exit;
  end;
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(result,'kid'));
stringMatch11 := CkStringBuilder_ContentsEqual(stringCompare,CkStringBuilder__getAsString(resourceId),True);
if (stringMatch11 <> True) then
  begin
    Memo1.Lines.Add('Response identifier does not match the requested version.');
    Exit;
  end;
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(result,'value'));
stringMatch12 := CkStringBuilder_ContentsEqual(stringCompare,'',True);
if ((CkJsonObject_JsonTypeOf(result,'value') <> 1) or (stringMatch12 = True)) then
  begin
    Memo1.Lines.Add('Missing or invalid value.');
    Exit;
  end;
validate35 := CkStringBuilder_Create();
alphabet35 := CkStringBuilder_Create();
success := CkStringBuilder_Append(validate35,CkJsonObject__stringOf(result,'value'));
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not validate encoded.');
    Exit;
  end;
success := CkStringBuilder_Append(alphabet35,'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_');
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not initialize validation.');
    Exit;
  end;
if ((CkStringBuilder_getLength(validate35) < 1) or (CkStringBuilder_getLength(validate35) > 10485760)) then
  begin
    Memo1.Lines.Add('Invalid encoded length.');
    Exit;
  end;
charIndex35 := 0;
while (charIndex35 < CkStringBuilder_getLength(validate35)) do
  begin
    if (CkStringBuilder_Contains(alphabet35,CkStringBuilder__getRange(validate35,charIndex35,1,False),True) <> True) then
      begin
        Memo1.Lines.Add('Invalid character in encoded.');
        Exit;
      end;
    charIndex35 := charIndex35 + 1;
  end;

ciphertext := CkJsonObject__stringOf(result,'value');
CkJsonObject_Clear(body);
success := CkJsonObject_UpdateString(body,'alg','RSA-OAEP-256');
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not set alg.');
    Exit;
  end;
success := CkJsonObject_UpdateString(body,'value',ciphertext);
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not set value.');
    Exit;
  end;
secondUrl := CkStringBuilder_Create();
success := CkStringBuilder_Append(secondUrl,CkStringBuilder__getAsString(resourceId));
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not construct URL or identifier.');
    Exit;
  end;
success := CkStringBuilder_Append(secondUrl,'/unwrapkey?api-version=2026-04-01');
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not construct URL or identifier.');
    Exit;
  end;
success := CkDateTime_SetFromCurrentSystemTime(now);
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not read current time.');
    Exit;
  end;
if (CkDateTime_DiffSeconds(expires,now) <= 60) then
  begin
    Memo1.Lines.Add('Token is expired or near expiration. Obtain a new token before continuing.');
    Exit;
  end;
success := CkHttp_HttpJson(http,'POST',CkStringBuilder__getAsString(secondUrl),body,'application/json',response);
if (success <> True) then
  begin
    Memo1.Lines.Add('Request failed; reconcile uncertain writes before retrying.');
    Exit;
  end;
if (CkHttpResponse_getStatusCode(response) <> 200) then
  begin
    Memo1.Lines.Add('Unexpected HTTP status; inspect request ID and diagnostics privately. Reconcile writes before retrying.');
    Exit;
  end;
success := CkJsonObject_Load(result,CkHttpResponse__bodyStr(response));
if (success <> True) then
  begin
    Memo1.Lines.Add('Invalid JSON response.');
    Exit;
  end;
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(result,'kid'));
stringMatch13 := CkStringBuilder_ContentsEqual(stringCompare,'',True);
if ((CkJsonObject_JsonTypeOf(result,'kid') <> 1) or (stringMatch13 = True)) then
  begin
    Memo1.Lines.Add('Missing or invalid kid.');
    Exit;
  end;
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(result,'kid'));
stringMatch14 := CkStringBuilder_ContentsEqual(stringCompare,CkStringBuilder__getAsString(resourceId),True);
if (stringMatch14 <> True) then
  begin
    Memo1.Lines.Add('Response identifier does not match the requested version.');
    Exit;
  end;
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(result,'value'));
stringMatch15 := CkStringBuilder_ContentsEqual(stringCompare,'',True);
if ((CkJsonObject_JsonTypeOf(result,'value') <> 1) or (stringMatch15 = True)) then
  begin
    Memo1.Lines.Add('Missing or invalid value.');
    Exit;
  end;
recovered := CkBinData_Create();
success := CkBinData_AppendEncoded(recovered,CkJsonObject__stringOf(result,'value'),'base64url');
if (success <> True) then
  begin
    Memo1.Lines.Add('Could not decode recovered bytes.');
    Exit;
  end;
CkStringBuilder_SetString(stringCompare,CkBinData__getEncoded(recovered,'hex'));
stringMatch16 := CkStringBuilder_ContentsEqual(stringCompare,CkBinData__getEncoded(plaintext,'hex'),True);
if (stringMatch16 <> True) then
  begin
    Memo1.Lines.Add('Recovered bytes do not match.');
    Exit;
  end;
Memo1.Lines.Add('Example completed.');

CkStringBuilder_Dispose(stringCompare);
CkJsonObject_Dispose(config);
CkStringBuilder_Dispose(validate1);
CkStringBuilder_Dispose(alphabet1);
CkStringBuilder_Dispose(vaultName);
CkStringBuilder_Dispose(letters);
CkStringBuilder_Dispose(origin);
CkHttp_Dispose(http);
CkHttpRequest_Dispose(request);
CkHttpResponse_Dispose(response);
CkJsonObject_Dispose(result);
CkJsonObject_Dispose(token);
CkDateTime_Dispose(expires);
CkDateTime_Dispose(now);
CkStringBuilder_Dispose(validate20);
CkStringBuilder_Dispose(alphabet20);
CkStringBuilder_Dispose(resourceBase);
CkStringBuilder_Dispose(validate21);
CkStringBuilder_Dispose(alphabet21);
CkStringBuilder_Dispose(resourceId);
CkStringBuilder_Dispose(getUrl);
CkJsonObject_Dispose(jwk);
CkPublicKey_Dispose(publicKey);
CkBinData_Dispose(plaintext);
CkPrng_Dispose(random);
CkJsonObject_Dispose(body);
CkStringBuilder_Dispose(firstUrl);
CkStringBuilder_Dispose(validate35);
CkStringBuilder_Dispose(alphabet35);
CkStringBuilder_Dispose(secondUrl);
CkBinData_Dispose(recovered);