Click here to Skip to main content
15,908,015 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: connection string Pin
Abhijit Jana21-Jan-09 23:18
professionalAbhijit Jana21-Jan-09 23:18 
AnswerRe: connection string Pin
saberbladez21-Jan-09 21:39
saberbladez21-Jan-09 21:39 
QuestionAccess Control from another form Pin
Ola E21-Jan-09 19:46
Ola E21-Jan-09 19:46 
AnswerRe: Access Control from another form Pin
Ashutosh Phoujdar22-Jan-09 0:35
Ashutosh Phoujdar22-Jan-09 0:35 
AnswerRe: Access Control from another form Pin
Ola E22-Jan-09 1:17
Ola E22-Jan-09 1:17 
GeneralRe: Access Control from another form Pin
Ben Fair22-Jan-09 6:21
Ben Fair22-Jan-09 6:21 
AnswerRe: Access Control from another form Pin
Ola E22-Jan-09 19:06
Ola E22-Jan-09 19:06 
Questionbinary file encryption Pin
Member 455503121-Jan-09 4:22
Member 455503121-Jan-09 4:22 
Hello, I'm trying to determine why this encryption won't work for binary files. (specifically docx) I can't use a filestream which is what I've read on a few boards and examples because I'm pulling the files from word and posting to a cloud service. Any Ideas? Am I just going about it wrong?

TIA,
foster


public static byte[] Cipher(byte[] PlainText, string InitialVector, string Salt, int KeySize, string PassPhrase, int PasswordIterations, string HashAlgorithm)
{
byte[] InitialVectorBytes = Encoding.ASCII.GetBytes(InitialVector);
byte[] SaltValueBytes = Encoding.ASCII.GetBytes(Salt);
System.Security.Cryptography.PasswordDeriveBytes DerivedPassword = new System.Security.Cryptography.PasswordDeriveBytes(PassPhrase, SaltValueBytes, HashAlgorithm, PasswordIterations);
byte[] KeyBytes = DerivedPassword.GetBytes(KeySize / 8);
System.Security.Cryptography.RijndaelManaged SymmetricKey = new System.Security.Cryptography.RijndaelManaged();
SymmetricKey.Mode = System.Security.Cryptography.CipherMode.CBC;
System.Security.Cryptography.ICryptoTransform Encryptor = SymmetricKey.CreateEncryptor(KeyBytes, InitialVectorBytes);
System.IO.MemoryStream MemStream = new System.IO.MemoryStream();
System.Security.Cryptography.CryptoStream CryptoStream = new System.Security.Cryptography.CryptoStream(MemStream, Encryptor, System.Security.Cryptography.CryptoStreamMode.Write);
CryptoStream.Write(PlainText, 0, PlainText.Length);
CryptoStream.FlushFinalBlock();
byte[] CipherTextBytes = MemStream.ToArray();
MemStream.Close();
CryptoStream.Close();
return CipherTextBytes;
}


public static byte[] Decipher(byte[] CipherText, string InitialVector, string Salt, int KeySize, string PassPhrase, int PasswordIterations, string HashAlgorithm)
{
byte[] InitialVectorBytes = Encoding.ASCII.GetBytes(InitialVector);
byte[] SaltValueBytes = Encoding.ASCII.GetBytes(Salt);
System.Security.Cryptography.PasswordDeriveBytes DerivedPassword = new System.Security.Cryptography.PasswordDeriveBytes(PassPhrase, SaltValueBytes, HashAlgorithm, PasswordIterations);
byte[] KeyBytes = DerivedPassword.GetBytes(KeySize / 8);
System.Security.Cryptography.RijndaelManaged SymmetricKey = new System.Security.Cryptography.RijndaelManaged();
SymmetricKey.Mode = System.Security.Cryptography.CipherMode.CBC;
System.Security.Cryptography.ICryptoTransform Decryptor = SymmetricKey.CreateDecryptor(KeyBytes, InitialVectorBytes);
System.IO.MemoryStream MemStream = new System.IO.MemoryStream(CipherText);
System.Security.Cryptography.CryptoStream cryptoStream = new System.Security.Cryptography.CryptoStream(MemStream, Decryptor, System.Security.Cryptography.CryptoStreamMode.Read);
byte[] PlainTextBytes = new byte[CipherText.Length];
int ByteCount = cryptoStream.Read(PlainTextBytes, 0, PlainTextBytes.Length);
MemStream.Close();
cryptoStream.Close();
return PlainTextBytes;
}
AnswerRe: binary file encryption Pin
Ben Fair22-Jan-09 5:59
Ben Fair22-Jan-09 5:59 
QuestionTimed GTalk Status Updater Pin
itsravie21-Jan-09 0:25
itsravie21-Jan-09 0:25 
AnswerRe: Timed GTalk Status Updater Pin
Dave Kreskowiak21-Jan-09 2:02
mveDave Kreskowiak21-Jan-09 2:02 
AnswerRe: Timed GTalk Status Updater Pin
Eddy Vluggen21-Jan-09 2:34
professionalEddy Vluggen21-Jan-09 2:34 
GeneralRe: Timed GTalk Status Updater Pin
Mohammad Dayyan21-Jan-09 8:52
Mohammad Dayyan21-Jan-09 8:52 
AnswerRe: Timed GTalk Status Updater Pin
itsravie25-Jan-09 12:07
itsravie25-Jan-09 12:07 
QuestionDeserialisation Problem with Generic Methods and Delegates Pin
mi220-Jan-09 22:43
mi220-Jan-09 22:43 
QuestionBCP process does not throw proper exceptions incase of any failures Pin
indian14320-Jan-09 19:52
indian14320-Jan-09 19:52 
AnswerSorry the message became too big as I am unable to edit it, again I am writing the question here [modified] Pin
indian14320-Jan-09 19:57
indian14320-Jan-09 19:57 
GeneralRe: Sorry the message became too big as I am unable to edit it, again I am writing the question here Pin
Dave Kreskowiak21-Jan-09 2:00
mveDave Kreskowiak21-Jan-09 2:00 
AnswerRe: BCP process does not throw proper exceptions incase of any failures Pin
Wendelius21-Jan-09 5:19
mentorWendelius21-Jan-09 5:19 
Question.Net Pin
Smtnri20-Jan-09 8:50
Smtnri20-Jan-09 8:50 
AnswerRe: .Net Pin
Not Active20-Jan-09 9:01
mentorNot Active20-Jan-09 9:01 
AnswerWow. Pin
leckey20-Jan-09 9:47
leckey20-Jan-09 9:47 
AnswerRe: .Net Pin
Pete O'Hanlon20-Jan-09 10:38
mvePete O'Hanlon20-Jan-09 10:38 
JokeRe: .Net Pin
0x3c020-Jan-09 10:52
0x3c020-Jan-09 10:52 
GeneralRe: .Net Pin
Mohammad Dayyan20-Jan-09 20:05
Mohammad Dayyan20-Jan-09 20:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.