I am trying to translate some perl code to python and I need some advice on making fixed sized strings. The perl code creates a sha1 signatured using a key and a 'pad'. It creates fixed sized strings as follows:
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? Next, it zero-fills a string to a certain size. if($klen <= $blen) { $key .= "\0"x($blen-length($key)); #zero-fill to blocksize } else { $key = sha1($key); #if longer, pre-hash key } Finally it concatenates and xors these strings together like this: return sha1($key^$opad . sha1($key^$ipad . $data)); I when python XOR's strings, is it the same as when perl xor's them? -- David Bear -- let me buy your intellectual property, I want to own your thoughts -- -- http://mail.python.org/mailman/listinfo/python-list