Skip to content

Instantly share code, notes, and snippets.

@VulBusters
Last active August 9, 2023 12:37
Show Gist options
  • Save VulBusters/5adc5b9e4aafd8845263f551fa010828 to your computer and use it in GitHub Desktop.
Save VulBusters/5adc5b9e4aafd8845263f551fa010828 to your computer and use it in GitHub Desktop.
private static byte[] GetSessionKey(byte[] sharedSecret)
{
String salt = PlayerPrefs.GetString(_PlayerPrefs.Salt);
if(String.IsNullOrEmpty(salt))
{
throw new PlayerPrefsItemNotFoundException(_PlayerPrefs.Salt);
}
var pdb = new Pkcs5S2ParametersGenerator(new Sha256Digest());
pdb.Init(sharedSecret, Conversion.StringToByteArray(salt), CryptoConstant.Iterations);
var key = (KeyParameter)pdb.GenerateDerivedMacParameters(CryptoConstant.KdfKeySize * 8);
return key.GetKey();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment