force key length to 8, pad if less and truncate if more

git-svn-id: file:///home/svn/framework3/trunk@11131 4d416f70-5f16-0410-b530-b9f4589650da
unstable
Joshua Drake 2010-11-24 20:57:26 +00:00
parent 10892a3fc3
commit 20dc5d57cf
1 changed files with 3 additions and 0 deletions

View File

@ -33,6 +33,9 @@ class Cipher
def self.mangle_password(password)
key = password || ''
key.slice!(8,key.length) if key.length > 8
key << "\x00" * (8 - key.length) if key.length < 8
# We have to mangle the key so the LSB are kept vs the MSB
[key.unpack('B*').first.scan(/.{8}/).map! { |e| e.reverse }.join].pack('B*')
end