Q:

Hash and Salt string in Windows Store App

I have been trying to do a Hash and salt on a password that I have to save on the device. This is a code that I have been using, but I can't find System.Security.Cryptography and the RNGCryptoServiceProvider in the Windows Store Framework.
public static string CreateSalt(int size)
{
    var rng = new RNGCryptoServiceProvider();
    var buff = new byte[size];
    rng.GetBytes(buff);
    return Convert.ToBase64String(buff);
}

public static string GenerateSHA256Hash(string input, string salt)
{
    byte[] bytes = System.Text.Encoding.UTF8.GetBytes(input + salt);
    SHA1Managed sha = new SHA1Managed();
    byte[] hash = sha.ComputeHash(bytes);

    return Convert.ToBase64String(hash);
}

Does anyone have an advise on how to do this on a Windows Store App?
Thanks

A:

There is an alternative to using RNGCryptoServiceProvider
var buffer = CryptographicBuffer.GenerateRandom(saltlength);
var string = CryptographicBuffer.EncodeToBase64String(buffer)

Windows.Security.Cryptography is the alternative to System.Security.Cryptography for windows store apps.

