Ordinarily I'd do something like this:
byte[] randomBytes = new byte[bytes];
string randomString = Convert.ToBase64String(new RNGCryptoServiceProvider().GetBytes(randomBytes));
However there's no RNGCryptoServiceProvider available.
Are there any secure random alternatives available?
Thanks,
I managed to find an equivalent.
using Windows.Security.Cryptography;
IBuffer randomBuffer = CryptographicBuffer.GenerateRandom(PASSWORD_SALT_LENGTH);
string randomString = CryptographicBuffer.EncodeToBase64String(randomBuffer)
I hope this is of use to someone else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With