-
Notifications
You must be signed in to change notification settings - Fork 3
Advanced _Scrypt
Chrono edited this page Dec 29, 2022
·
2 revisions
For detailed documentation, kindly refer to official libsodium.
It's extremely important that you follow the guidelines from libsodium to avoid having any sorts of security vulnerabilities and like what libsodium has stated.., don't use Scrypt unless you have a reason to use it.
Initial Functions
public static Byte[] PBKDF2(long DerivedKeyLength,Byte[] Password,Byte[] Salt,STRENGTH strength = STRENGTH.INTERACTIVE,Boolean ClearKey=false)
Example Code
Byte[] RandomPassword = SodiumRNG.GetRandomBytes(128);
Byte[] Salt = SodiumPasswordHashScryptSalsa208SHA256.GenerateSalt();
Byte[] DerivedKey = SodiumPasswordHashScryptSalsa208SHA256.PBKDF2(32, RandomPassword, Salt);
Initial Functions
public static Byte[] CustomPBKDF2(long DerivedKeyLength, Byte[] Password, Byte[] Salt, long OpsLimit,long MemLimit,Boolean ClearKey=false)
Example Code
Byte[] RandomPassword = SodiumRNG.GetRandomBytes(128);
Byte[] Salt = SodiumPasswordHashScryptSalsa208SHA256.GenerateSalt();
Byte[] DerivedKey = SodiumPasswordHashScryptSalsa208SHA256.CustomPBKDF2(32, RandomPassword, Salt, 1048576 ,33554432);
Initial Functions
public static Boolean VerifyPassword(String ComputedPasswordHashWithParams,Byte[] Password,Boolean ClearKey=false)
public static int HashedPasswordWithParamsNeedReHash(String ComputedPasswordHashWithParams,STRENGTH strength = STRENGTH.INTERACTIVE)
Example Code
Byte[] RandomPassword = SodiumRNG.GetRandomBytes(128);
String HashedPasswordWithParams = SodiumPasswordHashScryptSalsa208SHA256.ComputePasswordHash(RandomPassword);
int NeedsRehash = SodiumPasswordHashScryptSalsa208SHA256.HashedPasswordWithParamsNeedReHash(HashedPasswordWithParams);
MessageBox.Show(NeedsRehash.ToString());
Initial Functions
public static String ComputePasswordHash(Byte[] Password, STRENGTH strength = STRENGTH.INTERACTIVE,Boolean ClearKey=false)
Example Code
Byte[] RandomPassword = SodiumRNG.GetRandomBytes(128);
String HashedPasswordWithParams = SodiumPasswordHashScryptSalsa208SHA256.ComputePasswordHash(RandomPassword);
Boolean VerifyPassword = SodiumPasswordHashScryptSalsa208SHA256.VerifyPassword(HashedPasswordWithParams,RandomPassword);
Initial Functions
public static String CustomComputePasswordHash(Byte[] Password, long OpsLimit, long MemLimit,Boolean ClearKey=false)
Example Code
Byte[] RandomPassword = SodiumRNG.GetRandomBytes(128);
String HashedPasswordWithParams = SodiumPasswordHashScryptSalsa208SHA256.CustomComputePasswordHash(RandomPassword, 1048576, 33554432);
Boolean VerifyPassword = SodiumPasswordHashScryptSalsa208SHA256.VerifyPassword(HashedPasswordWithParams, RandomPassword);