Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What cryptographically secure options are there for creating random numbers in WinRT?

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,

like image 662
Tristan Warner-Smith Avatar asked Jan 29 '13 11:01

Tristan Warner-Smith


1 Answers

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.

like image 129
Tristan Warner-Smith Avatar answered Oct 02 '22 19:10

Tristan Warner-Smith