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 8115483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:29:45+00:00 2026-06-06T03:29:45+00:00

I asked this question over Security site, and people there suggested I should have

  • 0

I asked this question over Security site, and people there suggested I should have posted it here.

Some background. We have proprietary devices which run c over a proprietary OS and other devices which run a c# dll over a windows OS.
Both contact our Server via TCP connection, for our server both type of requests are the same.
The TCP server transfers part of the request to a self-hosted WCF service, through http-binding.
The requests are encrypted as shown in the link(like the C# dll encrypts them).

I am in the process of trying to cut off the TCP server and send requests straight to the WCF service.

My problem is that it seems like the WCF service receives the request string wrong, and it can’t decrypt it.

It seems like there are additional \t \n in the server side receives string. other than that it looks the same.

This is the decryption code on the server side:

            byte[] byteChiperText = Encoding.Default.GetBytes(input);

            if (k.Length != 16)
            {
                throw new Exception("Wrong key size exception");
            }
            TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider();

            des.Mode = CipherMode.ECB;
            des.Padding = PaddingMode.Zeros;
            des.Key = k;
            ICryptoTransform ic = des.CreateDecryptor();
            MemoryStream ms = new MemoryStream(byteChiperText);
            CryptoStream cStream = new CryptoStream(ms,
                 ic,
                 CryptoStreamMode.Read);
            StreamReader sReader = new StreamReader(cStream);
            byte[] data = new byte[byteChiperText.Length];
            int len = sReader.BaseStream.Read(data, 0, data.Length);
            output = Encoding.Default.GetString(data, 0, len);

            cStream.Close();
  • 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-06T03:29:46+00:00Added an answer on June 6, 2026 at 3:29 am

    Well this looks broken to start with:

    byte[] byteChiperText = Encoding.Default.GetBytes(input);
    

    You’re treating encrypted data as if it’s text encoded with the platform default encoding. That’s a great way to lose data. Encrypted data isn’t text. It’s arbitrary binary data, and should be treated as such.

    Instead, you should use base64 to encode the encrypted data as text (Convert.ToBase64String) and then reverse that (Convert.FromBase64String) later on to get back to the original cypher-text. That’s assuming you need it in text form to start with, of course. If you can pass it as a byte[] in the first place, that would be even better.

    Also note that your approach to getting the text out is somewhat odd – you’re creating a StreamReader, then only using the base stream. It would be better to use:

    // You should be using "using" statements for all your streams, by the way...
    using (TextReader reader = new StreamReader(cStream))
    {
        output = reader.ReadToEnd();
    }
    

    Note that this will use UTF-8 rather than the platform default encoding – but that’s a good thing, so long as you make the corresponding change in the encryption code. Using the platform default encoding is almost always a mistake – it may well not support all of Unicode, and it varies from machine to machine.

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

Sidebar

Related Questions

I asked this question to multiple people and until now I do not have
I have asked this question before - but I have spent some time thinking
I have asked this question in a different post here on SO: How can
I realize this question (or questions that look like this) have been asked over
I have asked this question in many sites and my question remain unanswered. Some
This question has frequently been asked over stackoverflow.com but none of the answers work
This question seems to be asked freqeuently over the internet but I still can't
This , question , is , asked , over , and , over ,
I asked this question earlier. I am intrigued by std::set but I have another
I asked this question over in the actual tutorial, but not sure I'll get

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.