0

how can we encrypt an executeable file using c# and make that encrypted file still executeable without using extra file for decryption?
mean the decryption methods shuold be inside file.
how can i write something like that with c# language?

thanks in adavance

10
  • Is the exe file you want to encrypt a .net assembly or a native executable? Commented Aug 15, 2012 at 10:46
  • 1
    And where does the decryption key come from? Does the user enter a password? Are you using proper key derivation techniques? Commented Aug 15, 2012 at 10:47
  • 4
    If you want to protect the executable from being examined by the user - you are aware that this will never provide 100% security? If the executable can decrypt itself, a skilled user can, too. Commented Aug 15, 2012 at 10:48
  • Exe needs a key, either from user or from some server via SSL. Commented Aug 15, 2012 at 10:53
  • @Pekka unless you ship an executable with no information in it, not very useful though. Commented Aug 15, 2012 at 10:53

1 Answer 1

2

Storing encrypted data on clients machine and having it decrypt automatically means that you will have to store decryption key on that machine as well. This means that you can't effectively protect data and provide it to user. Such encryption is only used to slow down user from tampering with the data as time is needed to recover decryption key and algorithm.

If you want to encrypt code of the executable itself, to prevent user from tampering with it, this is a very very complex topic. It's only matter of persistence and time. You will not get an answer to such question in one StackOverflow post. You'll have to study PE and .NET file formats, operating system internals regarding executable loader as well as mscor*.

If you need to store some data

  • choose some encryption algorithm and encrypt your data into a file (see this question)
  • add encrypted file to your c# project as embedded resourse
  • in runtime access this file (see this question) and decrypt it (already discussed in first point)
Sign up to request clarification or add additional context in comments.

1 Comment

ok man, thanks for the attention. but tampering of data is not important for me. i am looking for a solution for my scenario. just this!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.