"David Bear" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]

>  my $klen = length($key);
>  my $blen = 64;
>  my $ipad = chr(0x36)x$blen;
>  my $opad = chr(0x5c)x$blen;
>
> I don't know if I ever seen any way in python of created a fixed size
> string. Can anyone show me how to implement the same statements in python?

Certainly, you can create fixed-length strings in python:
>>> n = 7
>>> chr(0x36) * n
'6666666'

> I when python XOR's strings, is it the same as when perl xor's them?
No, XOR is a bitwise operation that does not apply to strings.

>>> 5 ^ 0
5
>>> 5 ^ 0xF
10
>>> 'a' ^ 'b'
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: unsupported operand type(s) for ^: 'str' and 'str'

See also the 'struct' module: http://docs.python.org/lib/module-struct.html


-- 
http://mail.python.org/mailman/listinfo/python-list
  • ... David Bear
    • ... \"Erik Johnson\" <ej <[EMAIL PROTECTED]>wellkeeper dot
    • ... Fredrik Lundh
    • ... David Bear

Reply via email to