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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:38:13+00:00 2026-06-01T21:38:13+00:00

i am planing to write a C# class library which will include my encryption

  • 0

i am planing to write a C# class library which will include my encryption algorithms like RC4, DES. These are single key encryption algorithms.
Now i want the best secure decision to protect my key. Should i put my key hardcoded inside the DLL or should i set my key from my external application which uses the DLL? Which one do you think is more secure when you consider the decompling tools?
Loudly thinking:

  • if the key is hardcoded in my security library and someone find the DLL and import it to his C# application, can he easly decode my chipper data?
  • if the key is not hardcoded in my security library but is set from my external application, someone needs to decompile also my external application to find my key?

Setting the key values from my external application which will use the security DLL seems more secure to me. What do you think?
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-01T21:38:15+00:00Added an answer on June 1, 2026 at 9:38 pm

    Hard Coded Key

    If you include the shared/private key in the DLL, then anyone who has a copy of the DLL will have a copy of the key. If your model is to share your application with multiple users, all users will have the same encryption key, and can decrypt anything encrypted by another user. If your application is easily available, then you have to assume the attacker has the application (and therefore the key) as well.

    It also means that all developers will have access to the production encryption key, since they have the source code. QE will also have access, as they probably have access to the binary. Either of these two insider groups will be able to decrypt anythign that your application protects for your customers.

    Is this what you want? It’s generally a bad practice, but it’s worse in some environments than others. For example, if you’re writing code to learn how to write crypto and nothing more, it probably doesn’t matter – just make sure nobody else can use it 🙂 If you’re writing a service, it’s a bad practice and introduces risk, but it’s not the worst thing you could do. If you’re writing something that will be shared to multiple customers, then you defeat the purpose of encrypting by including the key in the binary.

    And it’s not really that hard to generate random data (using a cryptographically strong random number generator), store it in a file, and use that file as your encryption key. My recommendation is go with the separate key.

    Separate Key

    If you ship the key in a separate file, you eliminate all the risks introduced by shipping the key in the binary but you introduce others. Or, stated differently, now that your crypto can do some good, you need to make sure you do it right or it’ll still be useless.

    The key needs to be generated using a cryptographically strong random number generator, so that it’s not predictable. The key needs to be stored securely – the whole path to the key file needs to be protected, and you should consider using a password protected store (like a keystore) to ensure that only users with the right password can access the key. Of course, that last one depends upon your deployment model, and if you need unattended restart. And the key needs to be used securely – constant order operations, don’t act an encryption or decryption oracle, verify integrity of data before semantically parsing it, etc.

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

Sidebar

Related Questions

I am trying to write a custom actions class library for my WiX install
I'm planning to write a web application (.net probably) that will need to analyze
We are planning to write an application that, in its start phase will be
I'm playing around trying to write a class for handling orm / database connectivity.
I have a class PlayingCard which represents a particular playing card. I have another
Ok here's what I'm trying to do I want to write a class that
I'm trying to write a callback class for my GUI windows. To (hopefully) achieve
I'm working on a Python library that interfaces with a web service API. Like
class tabBase { public: tabBase() { } virtual ~tabBase() { } virtual void write()
I am playing around with The Enterprise Library Validation Block. I have a class

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.