public static string EncryptString(HashType ht, string str, string salt = null) { switch (ht) { case HashType.Md5: var md5 = SaltMd5.Init(str, salt); return(md5.ToBfFormat()); } throw new PostfixEncryptorException("This hash type doesn't implemented."); }
public static SaltMd5 Init(string stringToHash, string salt) { if (salt != null && !salt.StartsWith(REQUIRED_MD5_SALT_PREFIX)) { throw new ArgumentException("Invalid salt format. Should be $1$********"); } var hash = new SaltMd5 { _stringToHash = stringToHash, _salt = salt }; return(hash); }