Monday, April 5, 2010

python-ldap error

I kept running into a
{'desc': 'Bad parameter to an ldap routine'}
error while trying to add a record from django. Turns out that in the form validation, I had a few fields defined as IntegerFields which means i was passing
('uidNumber', 5001)
instead of
('uidNumber', '5001')
to python-ldap. Casting to an ascii string works. Unicode doesn't

OpenSSL compatible encryption

I wanted to have a Perl program that encrypted a file using perl's Crypt::CBC and be able to decrypt it using the OpenSSL enc application. It took me awhile to figure this one out.

my $cipher = Crypt::CBC->new(
-key => "123",
-cipher => 'Blowfish',
-keysize => 128/8,
-header => 'salt'
);


This works with
openssl enc -bf-cbc -d -in /tmp/staging/passwd.gz.enc -out ah -pass pass:123


The same applies for other ciphers e.g
my $cipher = Crypt::CBC->new(
-key => "123",
-cipher => 'Rijndael',
-keysize => 128/8,
-header => 'salt'
);


This works with
openssl enc -aes-128-cbc -d -in /tmp/staging/passwd.gz.enc -out ah -pass pass:123


Inspiration from stackoverflow