use salt and password to create a key
This commit is contained in:
parent
7b731e22a4
commit
96a24d033b
@ -137,7 +137,7 @@ namespace EduNetworkBuilder
|
||||
|
||||
public static string GenSalt(Random RanGen)
|
||||
{
|
||||
return GenCharString(RanGen, 20);
|
||||
return GenCharString(RanGen, 50);
|
||||
}
|
||||
|
||||
public static string GenUserPW(Random RanGen)
|
||||
@ -145,5 +145,20 @@ namespace EduNetworkBuilder
|
||||
return GenCharString(RanGen, 6);
|
||||
}
|
||||
|
||||
public static TripleDES GenKey(string password, string salt)
|
||||
{
|
||||
TripleDESCryptoServiceProvider tDESkey = new TripleDESCryptoServiceProvider();
|
||||
byte[] saltBytes = Encoding.UTF8.GetBytes(salt);
|
||||
var p = new Rfc2898DeriveBytes(password, saltBytes);
|
||||
tDESkey.IV = p.GetBytes(tDESkey.BlockSize / 8);
|
||||
tDESkey.Key = p.GetBytes(tDESkey.KeySize / 8);
|
||||
return tDESkey;
|
||||
}
|
||||
|
||||
public void SetKey(string password, string salt)
|
||||
{
|
||||
algValue = GenKey(password, salt);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user