private string decryptPassword(string ConnectString) { int intStart = 0; int intEnd = 0; string EncryptedString = ""; string DecryptedString = ""; //parse the encrypted password from the connection string, then decrypt it //and update the connection string intStart = ConnectString.IndexOf("Password="******"Password="******";", intStart); if (intStart < intEnd) { //ok to decrypt EncryptedString = ConnectString.Substring(intStart, intEnd - intStart); // new style ASi.UtilityHelper.Utilities ut = new ASi.UtilityHelper.Utilities(); DecryptedString = ut.Decrypt(EncryptedString); ConnectString = ConnectString.Replace(EncryptedString, DecryptedString); } else { throw new Exception("Invalid connection string (2)"); } } else { throw new Exception("Invalid connection string (1)"); } return(ConnectString); }
public void SetPassword(string password) { /* * password encryption here * should use SecureString but can't without changing GenerateHash and Encrypt methods of UtilityHelper */ ASi.UtilityHelper.Utilities ut = new ASi.UtilityHelper.Utilities(); hashedPassword = ut.GenerateHash(password); encryptedPassword = ut.Encrypt(password); }