>I aam writing some software which calls for some unreadable code in > it to let me secretly set a registration key- it is to be shareware. > > I know this can be done, but have not the foggiest clue of how todo it. > Any links, articles, pointers?
This is impossible to do completely, and while you work on it, you will always feel that the protection is not enough because you understand it, and could easily circumvent it. Some possiblities: 1) Write registration validation in very clever and confusing C and then call with ctypes 2) At the very least, compile to pyc (IOW, don't distribute py, but the pyc that's generated when imported) 3) Use tricks... look for unreadable code and try to imitate it 4) Individual scenarios a) play with floats and strings, mix them, meld them, build sandcastles b) almost every good registration has a difficult to follow algorithm of arithmetic operations c) build hashes on certain times. d) Be creative Here's something interesting. ######### import time def genkey(name): #This is for you exclusively yr, mn, dy = time.localtime()[:3] ad = yr/5.0+6.0*mn%(dy+2) tsum=sum(ord(x) for x in name) return str(ad+tsum).replace(".",str(mn)) def chkkey(name,key,mn,dy,yr): ad = yr/5.0+6.0*mn%(dy+2) tsum=sum(ord(x) for x in name) ad = str(ad+tsum).replace(".",str(mn)) return ad==key ############# Not nearly creative enough I would think. The best thing I can come up with right now is to use a preexisting function in your application to also process your key. That's difficult, yes, but it will help discourage people from say~ changing the last line of my chkkey to return True Also, use obscure names. (Not that it will matter in pyc code) _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor