2

So I was wondering if there was any way to make a program in Visual C#.NET that can take in another program and encrypt the contents (effectively the machine code) of the program and then put that in a program that when run, decrypts the other program, and executes the decrypted program.

If it is possible, how?

Another off topic question: Could I use a Visual C#.NET GUI to write to a program (that would be determined by the user in the C# GUI) in a different programming language (such as writing it into HTML or PERL)?

Alper
  • 1
  • 12
  • 39
  • 78

4 Answers4

2

Short answer: Yes.

Long answer: Yes, but there is so very rarely a good reason to do this that I put it to you that you are using the wrong hammer on this particular screw. Now if you're attempting to make the resulting program compress much worse than the original, I stand corrected.

If you have a program that, without external input, automatically decrypts its contents and then executes them, then the contents are effectively in cleartext already, making the encryption useless against an attacker.

Slartibartfast
  • 1,694
  • 9
  • 8
0

I am not sure, but maybe you are looking for something like this.

For encryption / decryption use the algorithm of your choice. Twofish is always fine.

Hyperboreus
  • 31,997
  • 9
  • 47
  • 87
0

If you want to protect a .NET assembly, using a good obfuscator is a better solution than encryption. If you rely solely on encryption with the keys embeded in your code it can be a half hour task to extract the original exe. If you still wanna give it a try look at how netz is doing with compressing and packing (just google for netz and download sources)

cdel
  • 717
  • 7
  • 14
0

Be it a program, image, video or any other thing, its a file. So yes, you can use C# to encrypt any type of file. Here is an article on how to encrypt and decrypt files.

Before you really attempt anything that becomes a commercial product I suggest you study cryptography to prevent potential pit falls in implementation.

It is often said that it's not the cryptographic algorithm that is vulnerable but the implementation.

Also there are numerous questions asked on SO it self about encryption/decryption.

Ranhiru Jude Cooray
  • 19,542
  • 20
  • 83
  • 128