cryptostream

C# “Bad Data” exception when decrypting encrypted file

こ雲淡風輕ζ 提交于 2019-12-01 11:03:14
Hey I'm very new to encryption and decryption, or even the c# language to be honest. Basically, I have a tcp chat server that "saves" logs and encrypts the text file. This is how I encrypt (based from the MSDN sample): public static void EncryptFile(string strInputFileName, string strOutputFileName, string strKey) { FileStream fsIn = new FileStream(strInputFileName, FileMode.Open, FileAccess.Read); FileStream fsOut = new FileStream(strOutputFileName, FileMode.Create, FileAccess.Write); DESCryptoServiceProvider des = new DESCryptoServiceProvider(); des.Key = ASCIIEncoding.ASCII.GetBytes(strKey)

Encrypting and Decrypting String using a Java equilavent of the C# CryptoStream

一曲冷凌霜 提交于 2019-11-30 10:06:36
I am looking at developing an application in Java for a mobile platform operating system. I have developed an application in C# WPF for the Windows Environment. I am using a cryptostream in order to encrypt and decrypt a string using the following code. the code shown below is the encryption only public string encrypt(string encryptionString) { byte[] clearTextBytes = Encoding.UTF8.GetBytes(encryptionString); SymmetricAlgorithm rijn = SymmetricAlgorithm.Create(); MemoryStream ms = new MemoryStream(); byte[] rgbIV = Encoding.ASCII.GetBytes("ryojvlzmdalyglrj"); byte[] key = Encoding.ASCII

simple encrypting / decrypting in VB.Net

随声附和 提交于 2019-11-30 04:06:31
I'm trying to figure out how to encrypt / decrypt a string in VB.Net. I followed the example given here and wrote the following code (below). There's a text box, an "encrypt" button, and a "decrypt" button. The idea is to type something into the text box ("like 'hello world'"), click "encrypt", and see the encrypted version appear in the text box. Clicking "decrypt" should then take you back to the original string. But when I try to encrypt I get an error when I try to "FlushFinalBlock". The error is: "Length of the data to encrypt is invalid". The "decrypt" part is a total shot in the dark,

C# Decrypt bytes from SQL Server EncryptByPassPhrase?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 11:22:49
Following Replicate T-SQL DecryptByPassPhrase in C# , I am unable to get a simple encryption with MSSQL to descrypt in C#. The encrypted values in certain columns is necessary because the table is exported into Excel and Access on a regular basis so simple encryption is more than enough to "block" values without having to involve developers to (re)do views, etc. In SQL Server 2012: select EncryptByPassPhrase( N'hello' , N'world' ) -- returns 0x01000000AA959FFB3A8E4B06B734051437E198C8B72000A058ACE91D617123DA102287EB In C#: byte[] buf = System.Text.Encoding.UTF8.GetBytes(

simple encrypting / decrypting in VB.Net

坚强是说给别人听的谎言 提交于 2019-11-29 01:15:07
问题 I'm trying to figure out how to encrypt / decrypt a string in VB.Net. I followed the example given here and wrote the following code (below). There's a text box, an "encrypt" button, and a "decrypt" button. The idea is to type something into the text box ("like 'hello world'"), click "encrypt", and see the encrypted version appear in the text box. Clicking "decrypt" should then take you back to the original string. But when I try to encrypt I get an error when I try to "FlushFinalBlock". The

C# Decrypt bytes from SQL Server EncryptByPassPhrase?

家住魔仙堡 提交于 2019-11-28 04:38:14
问题 Following Replicate T-SQL DecryptByPassPhrase in C#, I am unable to get a simple encryption with MSSQL to descrypt in C#. The encrypted values in certain columns is necessary because the table is exported into Excel and Access on a regular basis so simple encryption is more than enough to "block" values without having to involve developers to (re)do views, etc. In SQL Server 2012: select EncryptByPassPhrase( N'hello' , N'world' ) -- returns