public string Decrypt(string encryptedString) { try { tripleDes.Key = CriptografiaDAO.MD5Hash("U&4v)G$KL$Lf55"); tripleDes.Mode = CipherMode.ECB; byte[] buffer = Convert.FromBase64String(encryptedString); return(ASCIIEncoding.ASCII.GetString(tripleDes.CreateDecryptor().TransformFinalBlock(buffer, 0, buffer.Length))); } catch (Exception) { return(string.Empty); } }
public string EncryptInterna(string stringToEncrypt) { try { tripleDes.Key = CriptografiaDAO.MD5Hash("U&4v)G$KL$Lf55"); tripleDes.Mode = CipherMode.ECB; byte[] buffer = ASCIIEncoding.ASCII.GetBytes(stringToEncrypt); KeyChave = null; return(Convert.ToBase64String(tripleDes.CreateEncryptor().TransformFinalBlock(buffer, 0, buffer.Length))); } catch (Exception ex) { throw new Exception(ex.Message); } }
public bool MensagemIncluir(List <MensagemController> mensagens) { try { CriptografiaDAO Cript = new CriptografiaDAO(); var con = new SqlConnection(ParametrosDAO.StringConexao); var sSql = new StringBuilder(); sSql.Append("INSERT INTO "); sSql.Append(" TB039_Mensagem "); sSql.Append(" ( "); sSql.Append(" TB041_id "); sSql.Append(" , TB012_id "); sSql.Append(" , TB013_id"); sSql.Append(" , TB009_id"); sSql.Append(" , TB039_Tipo"); sSql.Append(" , TB039_Assunto"); sSql.Append(" , TB039_Conteudo"); sSql.Append(" , TB039_DataCriacao"); sSql.Append(" , TB039_DataAgendamento"); sSql.Append(" , TB039_Status"); sSql.Append(" ) VALUES "); con.Open(); for (int i = 0; i < mensagens.Count; i++) { var sSqlI = new StringBuilder(); sSqlI.Append(" ("); sSqlI.Append(mensagens[i].TB041_id); sSqlI.Append(","); sSqlI.Append(mensagens[i].TB012_id); sSqlI.Append(","); sSqlI.Append(mensagens[i].TB013_id); sSqlI.Append(","); sSqlI.Append(mensagens[i].TB009_id); sSqlI.Append(","); sSqlI.Append(mensagens[i].TB009_TipoI); sSqlI.Append(","); sSqlI.Append("'"); sSqlI.Append(mensagens[i].TB039_Assunto); sSqlI.Append("'"); sSqlI.Append(","); sSqlI.Append("'"); sSqlI.Append(mensagens[i].TB039_Conteudo); sSqlI.Append("'"); sSqlI.Append(","); sSqlI.Append("'"); sSqlI.Append(DateTime.Now.ToString("MM/dd/yyy hh:mm")); sSqlI.Append("'"); sSqlI.Append(","); sSqlI.Append("'"); sSqlI.Append(mensagens[i].TB039_Agendamento.ToString("MM/dd/yyy hh:mm")); sSqlI.Append("'"); sSqlI.Append(","); sSqlI.Append(mensagens[i].TB012_StatusI); sSqlI.Append(")"); string insert = sSql.ToString() + sSqlI.ToString(); var command = new SqlCommand(insert, con); command.CommandTimeout = 300; command.ExecuteReader(); } con.Close(); } catch (Exception ex) { // ReSharper disable once PossibleIntendedRethrow throw ex; } return(true); }