-1

I've been searching for a while now and I can't seem to find any help on this one...

My scenario: I got a python/kivy project and I already got my python-files compiled using setup and cythozine().

My problem: I somehow have to compile, or at least obfuscate the .kv files. Please don't ask me why, I've seen many discussing it and mostly it goes nowhere. It was requested that way and I do not want to discuss it.

My solution so far: I inject the whole content of the .kv-File into the Builder.load_string() before compiling my scripts, but that whole string will appear in plain text in the compiled files after compiling them. It will take some time for someone to find it, but I think it's still not the best solution.

Hopefully someone can help me out here. ^^

EDIT:

I've already tried the following, so I could at least obfuscate the code: https://github.com/rdevost/pymixup Unfortunately, the pre-requisites gave me some problems.

I asked for the obfuscation, since it seems quite troublesome to compile it. So I thought it might be a compromise to obfuscate the kv-File, load it into the Builder and compile the py-File. With that, the kv part would still be in plain text inside the compiled file, but it would be obfuscated.

I'm running my application on a raspberry pi.

LanoChaos
  • 1
  • 3
  • You have to __compile__ _or_ __obfuscate__ ? What do you mean? These are not synonyms to ane another.. – WiseDev Jul 03 '19 at 10:51
  • Sorry, I should have made it more precise. I would like to compile it, but since it seems quite troublesome, it would be great at least to obfuscate it file, so I could load it into the Builder as an obfuscated string and compile it afterwards. With that, I wouldn't care, if the string is in plain text. – LanoChaos Jul 03 '19 at 11:10
  • but what exactly is troublesome about just compiling it? – WiseDev Jul 03 '19 at 11:11
  • I couldn't find any solution for this and was hoping to get some help here. ^^" I barely made the setup compile my py-files. I'm pretty new to this whole thing and only got it running with his help: https://medium.com/@xpl/protecting-python-sources-using-cython-dcd940bb188e – LanoChaos Jul 03 '19 at 11:17
  • What exactly are the requirements you want fullfilled? Is it enough if the kv string does not appear in plaintext? – syntonym Jul 08 '19 at 09:29
  • Yeah, that would be sufficient, I think. I used different modules, but cython always complains about their output while compiling the py-scripts. I inserted the kv-lang stuff into the py-scripts as a string into the kivy builder and tryied to compile the py-scripts afterwards with cython. – LanoChaos Jul 08 '19 at 10:08

1 Answers1

0

Ok... That was pretty simple. I just had some trouble figuring out how PyInstaller works. I used the simplest method of PyInstaller to compile it.

python -m PyInstaller --name Project-Name -p {Some custom Submodules-Path} main.py

Before doing that, I injected the kv-Language code into the py-script as an input-string for the kivy-module Builder.load_string(). Not as elegant as I hoped, but anyway... If someone has any idea how to include the kv-Lang files, I would appreciate it. I know one can add some hooks to it after creating the .spec of PyInstaller. kivy: Create a package for windows But that's it.

The result is significantly larger than before (setup + cythonize). But it works for me, since it's compiled and a bit obfuscated too so you can't read the code that easy. ^^

This might be a simple task, but it took me some time to figure it out.

LanoChaos
  • 1
  • 3
  • I think pyinstaller only zips the source files. If you're genuinely worried about people extracting the strings then it's done almost nothing. If you just want to say you did "something" to stop it then it may be ok – DavidW Jul 10 '19 at 06:22
  • As I said, I had some difficulties with this and it seemed like a simple solution that would at least make it difficult to extract the strings. I realize that it is not an ideal solution. But since everyone has been telling me, that there is no ideal one, I kept it that way. Do you have any tips or maybe even a better solution for this problem? – LanoChaos Jul 15 '19 at 10:32
  • No I really don't have any better solutions I'm afraid. This seems like a sensible compromise that makes it a little bit harder, but it is worth being aware of it's limitations I think – DavidW Jul 15 '19 at 11:18