P
Patrick De Ridder
The following code produces an error on the very last line, namely: An
unhandled exception of type
'System.Security.Cryptography.CryptographicException' occurred in
mscorlib.dll Additional information: Bad Data.
Please help; if you can with exactly which code I should change and how.
Patrick
****************************************************************
static public void putID(String strinput)
{
FileStream fs = new
FileStream("Param.txt",FileMode.Create,FileAccess.Write);
Console.WriteLine("Enter Some Text to be stored in encrypted file:");
Byte[] bytearrayinput=ConvertStringToByteArray(strinput);
DESCryptoServiceProvider des1 = new DESCryptoServiceProvider();
ICryptoTransform desencrypt = des1.CreateEncryptor();
CryptoStream cryptostream = new
CryptoStream(fs,desencrypt,CryptoStreamMode.Write);
cryptostream.Write(bytearrayinput,0,bytearrayinput.Length);
cryptostream.Close();
fs.Close();
}
static public String getID()
{
FileStream fsread = new
FileStream("Param.txt",FileMode.Open,FileAccess.Read);
DESCryptoServiceProvider des2 = new DESCryptoServiceProvider();
ICryptoTransform desdecrypt = des2.CreateDecryptor();
CryptoStream cryptostreamDecr = new
CryptoStream(fsread,desdecrypt,CryptoStreamMode.Read);
return( (new StreamReader(cryptostreamDecr, new
UnicodeEncoding())).ReadToEnd() );
}
****************************************************************
unhandled exception of type
'System.Security.Cryptography.CryptographicException' occurred in
mscorlib.dll Additional information: Bad Data.
Please help; if you can with exactly which code I should change and how.
Patrick
****************************************************************
static public void putID(String strinput)
{
FileStream fs = new
FileStream("Param.txt",FileMode.Create,FileAccess.Write);
Console.WriteLine("Enter Some Text to be stored in encrypted file:");
Byte[] bytearrayinput=ConvertStringToByteArray(strinput);
DESCryptoServiceProvider des1 = new DESCryptoServiceProvider();
ICryptoTransform desencrypt = des1.CreateEncryptor();
CryptoStream cryptostream = new
CryptoStream(fs,desencrypt,CryptoStreamMode.Write);
cryptostream.Write(bytearrayinput,0,bytearrayinput.Length);
cryptostream.Close();
fs.Close();
}
static public String getID()
{
FileStream fsread = new
FileStream("Param.txt",FileMode.Open,FileAccess.Read);
DESCryptoServiceProvider des2 = new DESCryptoServiceProvider();
ICryptoTransform desdecrypt = des2.CreateDecryptor();
CryptoStream cryptostreamDecr = new
CryptoStream(fsread,desdecrypt,CryptoStreamMode.Read);
return( (new StreamReader(cryptostreamDecr, new
UnicodeEncoding())).ReadToEnd() );
}
****************************************************************