Я хотел бы зашифровать данные в приложении UWP, написанном на JavaScript.
var publicKey = Windows.Security.Cryptography.Core.PersistedKeyProvider.openPublicKeyFromCertificate(cert, "", Windows.Security.Cryptography.Core.CryptographicPadding.none);
var buffer = Windows.Security.Cryptography.CryptographicBuffer.createFromByteArray(bytes);
var iv = null;
var encrypted = Windows.Security.Cryptography.Core.CryptographicEngine.encrypt(publicKey, buffer, iv);
Но я получаю исключение в последней строке:
0x80090027 - Ошибка времени выполнения JavaScript: Parameterr není správný.
(Неверный параметр)
Но какой параметр?
Сертификат создается командой
New-SelfSignedCertificate -Type Custom -Subject "test" -KeyAlgorithm RSA -KeyLength 2048 -CertStoreLocation "Cert:\CurrentUser\My"
и получено Windows.Security.Cryptography.Certificates.CertificateStores.