Referencias usadas:
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
Descifra un valor encriptado con la función anterior,
debemos pasarles las mismas claves.
*********************************************************************************
public string DescifrarValor(string sValor)
{
string sResultado = string.Empty;
TripleDESCryptoServiceProvider oTripleDESC =
new TripleDESCryptoServiceProvider();
try
{
byte[] bIN = Convert.FromBase64String(sValor);
using (MemoryStream oOutStream = new MemoryStream())
{
CryptoStream oCryptoStream =
new CryptoStream(oOutStream,
oTripleDESC.CreateDecryptor(bClave, bVector),
CryptoStreamMode.Write);
oCryptoStream.Write(bIN, 0, bIN.Length);
oCryptoStream.FlushFinalBlock();
sResultado = Encoding.UTF8.GetString(oOutStream.ToArray());
}
}
catch (Exception ex)
{
throw new System.Exception(ex.Message, ex.InnerException);
}
return sResultado;
}

No hay comentarios:
Publicar un comentario