Share via


SecureStorage Class

Definition

The SecureStorage API helps securely store simple key/value pairs.

public ref class SecureStorage abstract sealed
public static class SecureStorage
type SecureStorage = class
Public Class SecureStorage
Inheritance
SecureStorage

Remarks

Each platform uses the platform provided APIs for storing data securely:

  • iOS: Data is stored in KeyChain. Additional information on SecAccessible at: SecAccessible.
  • Android: Encryption keys are stored in KeyStore and encrypted data is stored in a named shared preference container (PackageId.microsoft.maui.essentials.preferences).
  • Windows: Data is encrypted with DataProtectionProvider and stored in a named ApplicationDataContainer (with a container name of ApplicationId.microsoft.maui.essentials.preferences).

NOTE: On Android devices running below API 23 (6.0 Marshmallow) there is no AES available in KeyStore. As a best practice this API will generate an RSA/ECB/PKCS7Padding key pair stored in KeyStore (the only type supported in KeyStore by these lower API levels), which is used to wrap an AES key generated at runtime. This wrapped key is stored in Preferences.

Properties

Default

Provides the default implementation for static usage of this API.

Methods

GetAsync(String)

Gets and decrypts the value for a given key.

Remove(String)

Removes a key and its associated value if it exists.

RemoveAll()

Removes all of the stored encrypted key/value pairs.

SetAsync(String, String)

Sets and encrypts a value for a given key.

Applies to