Click here to Skip to main content
15,895,142 members
Home / Discussions / C#
   

C#

 
AnswerRe: folderBrowserDialog is not visible while installing the application ? Pin
MikaEG27-Apr-09 9:54
MikaEG27-Apr-09 9:54 
GeneralRe: folderBrowserDialog is not visible while installing the application ? Pin
Dattatraya K27-Apr-09 19:55
Dattatraya K27-Apr-09 19:55 
Questioni need help with a cryptography exception! Pin
Roshanakak27-Apr-09 3:29
Roshanakak27-Apr-09 3:29 
AnswerRe: i need help with a cryptography exception! Pin
Simon P Stevens27-Apr-09 5:10
Simon P Stevens27-Apr-09 5:10 
QuestionRe: i need help with a cryptography exception! Pin
Roshanakak27-Apr-09 18:34
Roshanakak27-Apr-09 18:34 
AnswerRe: i need help with a cryptography exception! Pin
Simon P Stevens27-Apr-09 21:41
Simon P Stevens27-Apr-09 21:41 
GeneralRe: i need help with a cryptography exception! Pin
Roshanakak28-Apr-09 0:43
Roshanakak28-Apr-09 0:43 
GeneralRe: i need help with a cryptography exception! Pin
Simon P Stevens28-Apr-09 1:30
Simon P Stevens28-Apr-09 1:30 
I think the problem is the way you are reading data out of the memory stream. Use a stream reader instead of getting the bytes and doing unicode encoding. I suspect that is screwing things up. Then use a stream writer to put the string back into the memory stream when decrypting. (This works fine on my PC if I make that change)

Roshanakak wrote:
i don't know how else i can flush them!!!


You're not calling dispose no any of your streams. You should be using 'using' to properly dispose of the streams. Anything that has a dispose method should be created within a using block (or if not, make sure you call Dispose() in some other way - like in a finally block) Like this:
using (MemoryStream memStream = new MemoryStream())
{
    using (ICryptoTransform EncryptorDecryptor = Algorithm.CreateEncryptor(key, iv))
    {
        using (CryptoStream crStream = new CryptoStream(memStream, EncryptorDecryptor, CryptoStreamMode.Write))
        {
            using (StreamWriter strWriter = new StreamWriter(crStream))
            {
                strWriter.Write(s);

                strWriter.Flush();
                crStream.FlushFinalBlock();
            }
        }
    }
}


Also, you're using a bunch of member variables on the class that your just overwriting when you decrypt. Get rid of these and make them local variables in the method. That will prevent any crossover or leak of setup from one method to the other.

Simon

QuestionGridview Pin
pginnare27-Apr-09 3:28
pginnare27-Apr-09 3:28 
AnswerRe: Gridview Pin
AnilJayanti27-Apr-09 3:40
AnilJayanti27-Apr-09 3:40 
AnswerRe: Gridview Pin
Jimmanuel27-Apr-09 4:17
Jimmanuel27-Apr-09 4:17 
Questionhow to select or get all values in listbox at pageload Pin
sakthi06karthi27-Apr-09 3:14
sakthi06karthi27-Apr-09 3:14 
AnswerRe: how to select or get all values in listbox at pageload Pin
AnilJayanti27-Apr-09 3:25
AnilJayanti27-Apr-09 3:25 
Questionc# interoperability with TCL Pin
Seraph_summer27-Apr-09 2:28
Seraph_summer27-Apr-09 2:28 
AnswerRe: c# interoperability with TCL Pin
Michael Bookatz27-Apr-09 2:52
Michael Bookatz27-Apr-09 2:52 
QuestionHow to get returned value from TableAdapter.Update method ? Pin
hdv21227-Apr-09 2:27
hdv21227-Apr-09 2:27 
AnswerRe: How to get returned value from TableAdapter.Update method ? Pin
musefan27-Apr-09 3:13
musefan27-Apr-09 3:13 
GeneralRe: How to get returned value from TableAdapter.Update method ? Pin
hdv21227-Apr-09 3:32
hdv21227-Apr-09 3:32 
QuestionProblem : Add New Window Form in c# Pin
ddravin200027-Apr-09 2:24
ddravin200027-Apr-09 2:24 
AnswerRe: Problem : Add New Window Form in c# Pin
Michael Bookatz27-Apr-09 2:50
Michael Bookatz27-Apr-09 2:50 
Questiondataset with datagrid Pin
shefa' isied27-Apr-09 2:23
shefa' isied27-Apr-09 2:23 
AnswerRe: dataset with datagrid Pin
AnilJayanti27-Apr-09 3:10
AnilJayanti27-Apr-09 3:10 
Questionrad chart Pin
shefa' isied27-Apr-09 2:16
shefa' isied27-Apr-09 2:16 
AnswerRe: rad chart Pin
Colin Angus Mackay27-Apr-09 2:17
Colin Angus Mackay27-Apr-09 2:17 
Questionhow to read data Pin
kaushik_dass27-Apr-09 2:08
kaushik_dass27-Apr-09 2:08 

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.