birddseedd
Posts: 43
Joined: Fri Jan 04, 2019 3:28 pm

can a python file be made to run in a way that is not humanly readable?

Thu Jan 24, 2019 4:28 pm

can a python file be made to run in a way that is not humanly readable? a py file can be ran from command line. but it can also be opened in ide. this is all i know. but I would need to make it so customers can not just read the source code.

User avatar
DougieLawson
Posts: 36578
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: can a python file be made to run in a way that is not humanly readable?

Thu Jan 24, 2019 4:33 pm

Not possible. Even the *.pyc files can be decoded back to source code.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

birddseedd
Posts: 43
Joined: Fri Jan 04, 2019 3:28 pm

Re: can a python file be made to run in a way that is not humanly readable?

Thu Jan 24, 2019 4:38 pm

DougieLawson wrote:
Thu Jan 24, 2019 4:33 pm
Not possible. Even the *.pyc files can be decoded back to source code.
well that kinda blows. what about c? does that compile into an executable file?

User avatar
DougieLawson
Posts: 36578
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: can a python file be made to run in a way that is not humanly readable?

Thu Jan 24, 2019 4:41 pm

C/C++ is a compiled language. Those things aren't 100% secure. We spent lots of time and money reverse engineering compiled languages for YR2K so it's a common skill.

What is so special about your code?
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

birddseedd
Posts: 43
Joined: Fri Jan 04, 2019 3:28 pm

Re: can a python file be made to run in a way that is not humanly readable?

Thu Jan 24, 2019 4:44 pm

its a product i want to sell. but if they can easily get the code they can duplicate it and drag me into a huge legal battle

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24174
Joined: Sat Jul 30, 2011 7:41 pm

Re: can a python file be made to run in a way that is not humanly readable?

Thu Jan 24, 2019 4:57 pm

birddseedd wrote:
Thu Jan 24, 2019 4:44 pm
its a product i want to sell. but if they can easily get the code they can duplicate it and drag me into a huge legal battle
Intrigued by the legal battle comment. If it's your code, why would you get dragged in to a legal battle?

That said, most people cannot decompile C code, and there are ways of writing it that make it more difficult to understand (actually, that's most C code anyway)
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

W. H. Heydt
Posts: 11100
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: can a python file be made to run in a way that is not humanly readable?

Thu Jan 24, 2019 4:58 pm

birddseedd wrote:
Thu Jan 24, 2019 4:44 pm
its a product i want to sell. but if they can easily get the code they can duplicate it and drag me into a huge legal battle
You can only be dragged into a big legal battle if your code does something illegal, or you have violated someone else's copyright, patent, or license terms in writing your code.

On the other hand, if you copyright *your* code and sell it with a suitable license, you can drag *them* into a huge legal battle if they do something with your code that violates the license you put it under.

All of that said, I hope you realize that everything you write is dependent on the work of other people...unless you started with a pile of sand and wrote all of your own tools from first principles. (And even then, both hardware and software will be influenced by your own prior knowledge.)

mattmiller
Posts: 2136
Joined: Thu Feb 05, 2015 11:25 pm

Re: can a python file be made to run in a way that is not humanly readable?

Thu Jan 24, 2019 5:01 pm

Easy solution - rewrite it in Python 3 with a few decorators and async calls and that'l make it unreadable!

Sorry - old time Python2er having a bad day with Python3 today :)

In all seriousness, there have been many requests like this over the years and without going to tremendous lengths like creating encrypted partitions, its not worth trying to hide python code.

Compliled C/C++ etc are intrinsically much harder to reverse engineer and most people don't go to trouble of trying to reverse engineer them

The hackers will always be able to do this (attack always beats defence eventually)

birddseedd
Posts: 43
Joined: Fri Jan 04, 2019 3:28 pm

Re: can a python file be made to run in a way that is not humanly readable?

Thu Jan 24, 2019 5:03 pm

jamesh wrote:
Thu Jan 24, 2019 4:57 pm
birddseedd wrote:
Thu Jan 24, 2019 4:44 pm
its a product i want to sell. but if they can easily get the code they can duplicate it and drag me into a huge legal battle
Intrigued by the legal battle comment. If it's your code, why would you get dragged in to a legal battle?

That said, most people cannot decompile C code, and there are ways of writing it that make it more difficult to understand (actually, that's most C code anyway)
it would take a civil court to get them to stop selling my code/product and get repreations(sp) from them.

birddseedd
Posts: 43
Joined: Fri Jan 04, 2019 3:28 pm

Re: can a python file be made to run in a way that is not humanly readable?

Thu Jan 24, 2019 5:08 pm

mattmiller wrote:
Thu Jan 24, 2019 5:01 pm
Easy solution - rewrite it in Python 3 with a few decorators and async calls and that'l make it unreadable!

Sorry - old time Python2er having a bad day with Python3 today :)

In all seriousness, there have been many requests like this over the years and without going to tremendous lengths like creating encrypted partitions, its not worth trying to hide python code.

Compliled C/C++ etc are intrinsically much harder to reverse engineer and most people don't go to trouble of trying to reverse engineer them

The hackers will always be able to do this (attack always beats defence eventually)
looking for a c++ide now.

mfa298
Posts: 1387
Joined: Tue Apr 22, 2014 11:18 am

Re: can a python file be made to run in a way that is not humanly readable?

Thu Jan 24, 2019 5:18 pm

jamesh wrote:
Thu Jan 24, 2019 4:57 pm
That said, most people cannot decompile C code, and there are ways of writing it that make it more difficult to understand (actually, that's most C code anyway)
Better yet use Perl, that can be really unreadable! (look for some of the Obfuscated perl contests)
birddseedd wrote:
Thu Jan 24, 2019 4:44 pm
its a product i want to sell. but if they can easily get the code they can duplicate it and drag me into a huge legal battle
First off maybe determine the risk of someone actually doing that vs the cost of trying to defeat what might be a non threat. Or look at other ways of making money from your code (e.e. get them to pay for support rather than paying for the code).

birddseedd
Posts: 43
Joined: Fri Jan 04, 2019 3:28 pm

Re: can a python file be made to run in a way that is not humanly readable?

Thu Jan 24, 2019 5:26 pm

mfa298 wrote:
Thu Jan 24, 2019 5:18 pm
jamesh wrote:
Thu Jan 24, 2019 4:57 pm
That said, most people cannot decompile C code, and there are ways of writing it that make it more difficult to understand (actually, that's most C code anyway)
Better yet use Perl, that can be really unreadable! (look for some of the Obfuscated perl contests)
birddseedd wrote:
Thu Jan 24, 2019 4:44 pm
its a product i want to sell. but if they can easily get the code they can duplicate it and drag me into a huge legal battle
First off maybe determine the risk of someone actually doing that vs the cost of trying to defeat what might be a non threat. Or look at other ways of making money from your code (e.e. get them to pay for support rather than paying for the code).
perl would be easier for a noob?

Ernst
Posts: 1257
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: can a python file be made to run in a way that is not humanly readable?

Thu Jan 24, 2019 6:07 pm

birddseedd wrote:
Thu Jan 24, 2019 5:26 pm
mfa298 wrote:
Thu Jan 24, 2019 5:18 pm
jamesh wrote:
Thu Jan 24, 2019 4:57 pm
That said, most people cannot decompile C code, and there are ways of writing it that make it more difficult to understand (actually, that's most C code anyway)
Better yet use Perl, that can be really unreadable! (look for some of the Obfuscated perl contests)
birddseedd wrote:
Thu Jan 24, 2019 4:44 pm
its a product i want to sell. but if they can easily get the code they can duplicate it and drag me into a huge legal battle
First off maybe determine the risk of someone actually doing that vs the cost of trying to defeat what might be a non threat. Or look at other ways of making money from your code (e.e. get them to pay for support rather than paying for the code).
perl would be easier for a noob?
No.
The road to insanity is paved with static ip addresses

birddseedd
Posts: 43
Joined: Fri Jan 04, 2019 3:28 pm

Re: can a python file be made to run in a way that is not humanly readable?

Thu Jan 24, 2019 6:21 pm

Ernst wrote:
Thu Jan 24, 2019 6:07 pm
birddseedd wrote:
Thu Jan 24, 2019 5:26 pm
mfa298 wrote:
Thu Jan 24, 2019 5:18 pm


Better yet use Perl, that can be really unreadable! (look for some of the Obfuscated perl contests)



First off maybe determine the risk of someone actually doing that vs the cost of trying to defeat what might be a non threat. Or look at other ways of making money from your code (e.e. get them to pay for support rather than paying for the code).
perl would be easier for a noob?
No.
lol. doesn't get any more straightforward than that.
i looked at wiringpi for a c++library. seems it only allows 1 pwm pin. am I correct? that seems like a pretty big limitation. I need at least 2 motors

hortimech
Posts: 334
Joined: Wed Apr 08, 2015 5:52 pm

Re: can a python file be made to run in a way that is not humanly readable?

Thu Jan 24, 2019 7:59 pm

birddseedd wrote:
Thu Jan 24, 2019 6:21 pm
i looked at wiringpi for a c++library. seems it only allows 1 pwm pin. am I correct? that seems like a pretty big limitation. I need at least 2 motors
There's another problem, if you use code from another project and that program has a GPL license, you will also have to provide the source code for your project.

SteveSpencer
Posts: 351
Joined: Thu Mar 28, 2013 9:19 am
Location: Nottingham, UK

Re: can a python file be made to run in a way that is not humanly readable?

Fri Jan 25, 2019 9:14 am

Pigpiod does multiple PWM, doesn't it?
And you use it as is, through a server interface, so as I understand it, you aren't obliged to supply the source (IANAL applies) for your client, just as using TCP/IP doesn't oblige you to provide the source for the network layer.
Of course, if you're using other libraries directly in your code, that may well change things.
Steve S
No, I can't think of anything funny that won't offend someone if they want it to...

Return to “Beginners”