ANN: obfuscate

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Tue Feb 9 19:29:31 EST 2010


En Tue, 09 Feb 2010 20:27:13 -0300, Stef Mientki <stef.mientki at gmail.com>  
escribió:
> 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 brunningonline.net> wrote:
>>>> On 9 February 2010 16:29, Robert Kern <robert.kern at gmail.com> 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)
'3\x1e\x17\x17\x14[\x0c\x14\t\x17\x1fZ'
>>> xor(_, 123)
'Hello world!'

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

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

(untested)

-- 
Gabriel Genellina




More information about the Python-list mailing list