示例#1
0
        public static string Criptografar(string texto)
        {
            string textoCriptografado = null;

            byte[] buffer = null;

            try
            {
                if (!string.IsNullOrEmpty(texto))
                {
                    buffer             = ASCIIEncoding.ASCII.GetBytes(texto);
                    textoCriptografado = Convert.ToBase64String(CriptografiaTripleDes.CreateEncryptor().TransformFinalBlock(buffer, 0, buffer.Length));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                CriptocriptografiaMd5 = null;
                CriptografiaTripleDes = null;
                buffer = null;
                texto  = null;
            }

            return(textoCriptografado);
        }