Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7864133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:41:43+00:00 2026-06-02T23:41:43+00:00

I encrypted a file using DES then After decrypting it successfully at the server

  • 0

I encrypted a file using DES then After decrypting it successfully at the server and using

System.IO.File.WriteAllBytes(@"c:\test\" + fileName, decryptedFile);

method the file data changed a little it the text is “Encrypting and Decrypting usind DES blah blah blah blah”
the text in the end file after decrypting is ” k$nlng and Decrypting usind DES blah blah blah blah”
and i also tried this:

using (BinaryWriter binWriter =
                        new BinaryWriter(File.Open(@"C:\Test\" + fileName, FileMode.Create)))
                {
                    binWriter.Write(decryptedFile);
                }

the text still not the same
encrypting by :

public byte [] DESEncrypt(byte [] fileBytes)
    {
        CryptoStreamMode mode = CryptoStreamMode.Write;

        // Set up streams and encrypt
        MemoryStream memStream = new MemoryStream();
        CryptoStream cryptoStream = new CryptoStream(memStream, 
            cryptoProvider.CreateEncryptor(cryptoProvider.Key, cryptoProvider.Key), mode);
        cryptoStream.Write(fileBytes, 0, fileBytes.Length);
        cryptoStream.FlushFinalBlock();

        // Read the encrypted message from the memory stream
        byte[] encryptedMessageBytes = new byte[memStream.Length];
        memStream.Position = 0;
        memStream.Read(encryptedMessageBytes, 0, encryptedMessageBytes.Length);
        MessageBox.Show("encrypted DES");
        return encryptedMessageBytes;
    }

decrypting by:

static public byte[] DESdecrypt(byte [] fileBytes)
    {

        ICryptoTransform decryptor = cryptoProvider.CreateDecryptor();
        byte[] originalAgain = decryptor.TransformFinalBlock(fileBytes, 0, fileBytes.Length);

        return originalAgain;
    }

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T23:41:45+00:00Added an answer on June 2, 2026 at 11:41 pm

    You are passing the same value for your “key” and “iv” value. Each time you call the function, your “iv” value gets updated (thus, your key gets changed).

    So you basically are doing this:

    key = “key”
    Encrypt (key, key)

    — key has now changed.

    What you need to do is:

    key = “key”
    iv = copy of key
    Encrypt (key, iv)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I encrypted a file in android using triple des. This file is uploaded to
I would like to decrypt a file that I previously encrypted with C# using
I'm trying to read encrypted struct data from file using fread(). once i get
I'm trying to encrypt a text file using Perl and then decrypt it using
I have created a .net application that is currently using a encrypted text file
in my program, I am encrypting and decrypting a .PNG file using the Triple
I have a file encrypted using the following code in c: unsigned char ckey[]
I've implemented a HTTP server (CherryPy and Python) that receives an encrypted file from
I have encrypted every item in MS Access file using AES. Encryption works great.
I've encrypted the connectionstring in my web.config file using the steps in the link

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.