ANN: obfuscate

Gabriel Genellina gagsl-py2 at
Wed Feb 10 01:29:31 CET 2010

En Tue, 09 Feb 2010 20:27:13 -0300, Stef Mientki <stef.mientki at>  
> On 10-02-2010 00:09, Alf P. Steinbach wrote:
>> * David Robinow:
>>> On Tue, Feb 9, 2010 at 5:10 PM, Simon Brunning  
>>> <simon at> wrote:
>>>> On 9 February 2010 16:29, Robert Kern <robert.kern at> wrote:
>>>>> On 2010-02-09 09:37 AM, Daniel Fetchinson wrote:
>>>>>> If the code base stabilizes in a production version after losing the
>>>>>> alphas and betas they would be a great addition to the stdlib, I
>>>>>> think.
>>>>> Why?
>>>> I agree. Why wait? Put them in the stdlib now!
>>> Can we please stop this?
>> I agree.
> sorry I don't,
> unless Python is only meant for the very well educated people in  
> encryption.
>> I haven't looked at the code but the functionality that's listed is  
>> useful, e.g. in a Usenet client, and it's fun to play around with for a  
>> beginner.
> I neither did look at the code,
> but as a beginner with just 3 years of experience in Python,
> I've tried several scrambling libs, for a quick and dirty use.
> All were much too difficult, so I made my own xor-something.
> Coming from Delphi, a scrambling lib is working is less than 10 minutes,  
> without the need of any knowledge of encryption.
> I prefer Python over Delphi, but some things are made very complex in  
> Python.

Are you sure?

>>> def xor(s, key):
...   return ''.join(chr(ord(c)^key) for c in s)
>>> txt = "Hello world!"
>>> xor(txt, 123)
>>> xor(_, 123)
'Hello world!'

The Delphi code would be certainly longer than that, some variation of:

function encrypt_xor(const s: string; key: integer);
   i: integer;
   SetLength(Result, length(s));
   for i:=1 to length(s) do
     Result[i] := chr(ord(s[i]) xor key);


Gabriel Genellina

More information about the Python-list mailing list