我需要生成一个AES密钥并将其发送到服务器。
创建密钥似乎不是问题:
var aesProvider = SymmetricKeyAlgorithmProvider.OpenAlgorithm(SymmetricAlgorithmNames.AesEcbPkcs7);
var aesKey = aesProvider.CreateSymmetricKey(CryptographicBuffer.GenerateRandom(16));
但是,将AES密钥导出为base64编码的字符串似乎是不可能的;
我尝试使用关键对象上的Export / ExportPublic方法导出它,但它们都抛出NotImplemented异常:
aesKey.ExportPublicKey(); not implemented
aesKey.ExportPublicKey(CryptographicPublicKeyBlobType.BCryptPublicKey);
aesKey.ExportPublicKey(CryptographicPublicKeyBlobType.Capi1PublicKey);
aesKey.Export();
aesKey.Export(CryptographicPrivateKeyBlobType.BCryptPrivateKey);
aesKey.Export(CryptographicPrivateKeyBlobType.Pkcs1RsaPrivateKey);
aesKey.Export(CryptographicPrivateKeyBlobType.Pkcs8RawPrivateKeyInfo);
aesKey.Export(CryptographicPrivateKeyBlobType.Capi1PrivateKey);