Isolated Storage -Business Central

  procedure SetAPIKey(NewAPIKey: Text)

var EncryptionManagement: Codeunit "Cryptography Management"; begin if IsolatedStorage.Contains(GetStorageKey(), DataScope::Module) then IsolatedStorage.Delete((GetStorageKey())); if EncryptionManagement.IsEncryptionEnabled() and EncryptionManagement.IsEncryptionPossible() then NewAPIKey := EncryptionManagement.Encrypt(NewAPIKey); IsolatedStorage.set(GetStorageKey(), NewAPIKey, DataScope::Module); end; procedure GetAPIKey(): Text var EncryptionManagement: Codeunit "Cryptography Management"; APIKey: Text; begin if IsolatedStorage.Contains(GetStorageKey(), DataScope::Module) then begin IsolatedStorage.Get(GetStorageKey(), DataScope::Module, APIKey); if EncryptionManagement.IsEncryptionEnabled() and EncryptionManagement.IsEncryptionPossible() then APIKey := EncryptionManagement.Decrypt(APIKey); exit(APIKey); end; end; local procedure GetStorageKey(): Text begin exit(SystemId); end;

No comments:

Post a Comment