2

I'm trying to compile python file with Cython and it's compiled to .c file Then I'm using gcc to encryption What is the best way to do this

I'm doing it like this :

cython -a test.py

then :

gcc -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing -I/usr/include/python2.7 -o test.so test.c

but someone told me he decryption my file and see the code What is the best way to encrypt with GCC

thanks.

vevo demo
  • 23
  • 1
  • 4

2 Answers2

0

What encryption? There isn't any. What you have produced is a shared library - a .so file.

This can be inspected for symbols and disassembled but you can't trivially recover the original Python or C code.

mhawke
  • 84,695
  • 9
  • 117
  • 138
  • is there any way to encrypt .c file ? – vevo demo Mar 26 '15 at 08:15
  • Yes, but it will not be of use because it still requires compilation before it can be executed. In general it is impractical because it will always be possible for a determined user to reverse engineer any software. – mhawke Mar 26 '15 at 08:48
0

Compiling is not the same thing as encryption. Compiling code is intended to make it executable by a machine or a virtual machine / language runtime. Although it is usually not possible to decompile a compiled program into the original source code (or even something close to it), it is often possible to recover something resembling the original source code.

The extent to which this is possible depends on a number of factors including:

  • the original language
  • the compiler used
  • the number of intermediate representations involved in the compilation process
  • how aggressively the compiler has optimised the code (usually a compiler option)
  • whether debugging symbols have been stripped from the resultant executable
frasertweedale
  • 5,424
  • 3
  • 26
  • 38
  • is there any way to encrypt .c file – vevo demo Mar 26 '15 at 08:18
  • or encrypt python file – vevo demo Mar 26 '15 at 08:19
  • @vevo demo: Yes, but neither will then be usable by their respective compilers. The best you can do is to obfuscate the code (which some programmers do unintentionally). – cdarke Mar 26 '15 at 08:36
  • @vevodemo what is your goal? What do you want to achieve, and why? – frasertweedale Mar 26 '15 at 08:54
  • I'm make some script with Python and some people stole my work :-( I need to some thing to protect my code just this – vevo demo Mar 26 '15 at 09:05
  • @vevodemo it is not easy to prevent people copying your code, especially with scripting languages like Python where the source code itself constitutes the usual executable form of the program. But assuming you have copyright in the code, you may have legal remedy. Alternatively you could use an instrument like copyleft to make your code available but require other people to publish their changes when they redistribute the program. (Disclaimer: *I am not a lawyer*) – frasertweedale Mar 26 '15 at 09:08
  • Disclaimer: I am not a lawyer ... LOOOL .ok thank u In my country there is no copyright :-D. – vevo demo Mar 26 '15 at 09:13