예제 #1
0
파일: FSCAuth.cs 프로젝트: Earlz/lucidmvc
 HashWithSalt DefaultHasher(string plain, string salt)
 {
     var v=new HashWithSalt();
     if(salt==null){
         v.Salt=HashHelper.GetSalt(Config.SaltLength);
     }else{
         v.Salt=salt;
     }
     HashAlgorithm hash;
     if(SupportsUnmanagedCrypto){
         hash=new SHA256CryptoServiceProvider();
     }else{
         hash=new SHA256Managed();
     }
     v.Text=HashHelper.FromBytes(hash.ComputeHash(HashHelper.ToRawBytes(plain+v.Salt)));
     return v;
 }
예제 #2
0
파일: FSCAuth.cs 프로젝트: Earlz/lucidmvc
 /// <summary>
 /// Computes a new hash and gets a new salt
 /// </summary>
 HashWithSalt NewHash(string input)
 {
     HashWithSalt v=new HashWithSalt();
     v.Text=input;
     v.Salt=null;
     v=Config.HasherInvoker(v.Text,v.Salt);
     return v;
 }
예제 #3
0
파일: FSCAuth.cs 프로젝트: Earlz/lucidmvc
 /// <summary>
 /// Computes a hash using an existing salt 
 /// </summary>
 string ComputeHash(string input, string salt)
 {
     Debug.Assert(salt != null);
     HashWithSalt v=new HashWithSalt();
     v.Text=input;
     v.Salt=salt;
     v=Config.HasherInvoker(v.Text,v.Salt);
     return v.Text;
 }