public string GetConnectionString() { var connectionString = _connectionStringProvider.Read(); if (string.IsNullOrWhiteSpace(connectionString)) { throw new Exception("impossible d'obtenir la chaine de connexion"); } var builder = new DbConnectionStringBuilder(); builder.ConnectionString = connectionString; if (!builder.ContainsKey("password")) { return(connectionString); } var password = builder["password"] as string; if (password.Contains("secret:")) { var decryptedPassword = DecryptStringFromBytes_Aes(Convert.FromBase64String(password.Remove(0, 7)), Key, Iv); builder["password"] = decryptedPassword; return(builder.ConnectionString); } builder["password"] = "******" + Convert.ToBase64String(EncryptStringToBytes_Aes(password, Key, Iv)); _connectionStringProvider.Write(builder.ConnectionString); return(connectionString); }