bcquality/microsoft/knowledge/security/isolatedstorage-setencrypted-for-sensitive-values.good.al
Jesper Schulz-Wedde ec8f891954 Correct security and privacy guidance
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 9c2eebc4-dcd5-4b85-8113-90772d818900
2026-07-14 10:45:42 +02:00

18 lines
610 B
AL

codeunit 50217 "Sec Sample SetEncrypted Good"
{
internal procedure StoreApiKey(ApiKeyValue: SecretText)
var
StoreApiKeyFailedErr: Label 'The API key could not be stored.';
begin
if not IsolatedStorage.SetEncrypted('ApiKey', ApiKeyValue, DataScope::Module) then
Error(StoreApiKeyFailedErr);
end;
local procedure ReadApiKey(var ApiKey: SecretText): Boolean
begin
if not IsolatedStorage.Contains('ApiKey', DataScope::Module) then
exit(false);
IsolatedStorage.Get('ApiKey', DataScope::Module, ApiKey);
exit(true);
end;
}