Re: help tranlating perl expressions
- From: "Erik Johnson" <ej <at> wellkeeper dot <com>>
- Date: Thu, 28 Sep 2006 11:23:25 -0600
"David Bear" <david.bear@xxxxxxx> wrote in message
news:5452284.reKt6RD0Uf@xxxxxxxxxx
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:
'6666666'n = 7
chr(0x36) * n
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.
55 ^ 0
105 ^ 0xF
Traceback (most recent call last):'a' ^ 'b'
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
.
- References:
- help tranlating perl expressions
- From: David Bear
- help tranlating perl expressions
- Prev by Date: Re: Questions on Using Python to Teach Data Structures and Algorithms
- Next by Date: ctypes.c_void_p(-1) might not be C return (void *) -1
- Previous by thread: help tranlating perl expressions
- Next by thread: Re: help tranlating perl expressions
- Index(es):
Relevant Pages
|