在WinRT中创建随机数的加密安全选项是什么?

Tri*_*ith 13 random cryptography windows-8 windows-runtime

通常我会做这样的事情:

byte[] randomBytes = new byte[bytes];
string randomString = Convert.ToBase64String(new RNGCryptoServiceProvider().GetBytes(randomBytes));
Run Code Online (Sandbox Code Playgroud)

但是没有RNGCryptoServiceProvider可用.

有没有安全的随机选择?

谢谢,

Tri*_*ith 18

我设法找到一个等价物.

using Windows.Security.Cryptography;

IBuffer randomBuffer = CryptographicBuffer.GenerateRandom(PASSWORD_SALT_LENGTH);
string randomString = CryptographicBuffer.EncodeToBase64String(randomBuffer)
Run Code Online (Sandbox Code Playgroud)

我希望这对其他人有用.