G
Guest
Hi I have the following code
private string GetUser()
{
Decryption decrypt = new Decryption();
return (string) decrypt.DecodeText("agyL70eOPb=", key);
}
which calls this static method
public class Decryption
{
public static string DecodeText(string encrypted, string source)
{
string decrypted;
TripleDESCryptoServiceProvider des;
MD5CryptoServiceProvider hashmd5;
byte[] pwdhash, buff;
hashmd5 = new MD5CryptoServiceProvider();
pwdhash = hashmd5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(source));
hashmd5 = null;
des = new TripleDESCryptoServiceProvider();
des.Key = pwdhash;
des.Mode = CipherMode.ECB;
buff = Convert.FromBase64String(encrypted);
decrypted = ASCIIEncoding.ASCII.GetString(des.CreateDecryptor
().TransformFinalBlock(buff, 0, buff.Length));
des = null;
return decrypted;
}
}
Is there a way to get rid of the 'new' line from the calling code
ie
private string GetUser()
{
return (string) DecodeText("agyL70eOPb=", key);
}
does not seem to work.
private string GetUser()
{
Decryption decrypt = new Decryption();
return (string) decrypt.DecodeText("agyL70eOPb=", key);
}
which calls this static method
public class Decryption
{
public static string DecodeText(string encrypted, string source)
{
string decrypted;
TripleDESCryptoServiceProvider des;
MD5CryptoServiceProvider hashmd5;
byte[] pwdhash, buff;
hashmd5 = new MD5CryptoServiceProvider();
pwdhash = hashmd5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(source));
hashmd5 = null;
des = new TripleDESCryptoServiceProvider();
des.Key = pwdhash;
des.Mode = CipherMode.ECB;
buff = Convert.FromBase64String(encrypted);
decrypted = ASCIIEncoding.ASCII.GetString(des.CreateDecryptor
().TransformFinalBlock(buff, 0, buff.Length));
des = null;
return decrypted;
}
}
Is there a way to get rid of the 'new' line from the calling code
ie
private string GetUser()
{
return (string) DecodeText("agyL70eOPb=", key);
}
does not seem to work.