Blazor WebAssembly does not support the System.Security.Cryptography.Aes class due to browser sandbox constraints. When attempting to use AES, you will encounter a PlatformNotSupportedException, indicating that the algorithm is not supported on this platform. This limitation is because Microsoft cannot ship OpenSSL as a dependency in the Blazor WebAssembly configuration, and attempts to integrate with the browser's SubtleCrypto API have not been successful.
As a result, developers are required to use JavaScript interop with the Web Crypto API or external libraries like CryptoJS to implement symmetric encryption in Blazor WebAssembly applications. This situation can lead to inconsistencies between .NET platforms and necessitates duplicating logic across client and server applications.
Currently, there are no good workarounds to implement AES directly in C# for Blazor WebAssembly, and the recommended approach is to utilize JavaScript interop for cryptographic operations.
References: