Hi, I'm doing it like public static void DecryptFile(string sInputFilename, string sOutputFilename, string sKey) What am I doing wrong? Why memory stream behave differently? OStream.Read(bytearrayinput, 0, bytearrayinput.Length) īut if I take one of my old encrypted file, decrypt it, encrypt it again with the memory encryption and decrypt it again, the file is then corrupted. So I build public static void EncryptFileFromMemory(String sOutputFilename, MemoryStream oStream, String sKey) Throw new System.ApplicationException("The encryption of the file failed") ICryptoTransform desencrypt = DES.CreateEncryptor() ĬryptoStream cryptostream = new CryptoStream(fsEncrypted, desencrypt, CryptoStreamMode.Write) īyte bytearrayinput = new byte įsInput.Read(bytearrayinput, 0, bytearrayinput.Length) Ĭryptostream.Write(bytearrayinput, 0, bytearrayinput.Length) My base method is: public static void EncryptFile(String sInputFilename, String sOutputFilename, String sKey)įileStream fsInput = new FileStream(sInputFilename, FileMode.Open, FileAccess.Read) įileStream fsEncrypted = new FileStream(sOutputFilename, FileMode.Create, FileAccess.Write) ĭESCryptoServiceProvider DES = new DESCryptoServiceProvider() ĭES.Key = (sKey) ĭES.IV = (sKey) Hi, I would like to create function to encrypt dataset in ecrypted text file and in order to avoid using a temporary file, I would like to create an EncryptToMemory function.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |