I have a python function: 

import from Crypto.Cipher import Blowfish
import binascii

def decrypt_password(encode):
     key = 'aa11k55544332211aabbaabbaaddccbb'
     blowfish = Blowfish.new(key, Blowfish.MODE_ECB)
     packed_password = blowfish.decrypt(binascii.unhexlify(encode))
     return packed_password

My Golang code is like:

func DecodePassword(pwd string) (decoded string, err error) {
h, err := hex.DecodeString(pwd)
if err != nil {
return
}
var dst = make([]byte, len(h))
cipher, err := blowfish.NewCipher([]byte(blowfishKey))
if err != nil {
return
}
cipher.Decrypt(dst, h)
decoded = string(dst)
return
}

the result of Python is like "Vmt7?m3My\x07\x07\x07\x07\x07\x07\x07" , the 
first 9 bytes is useful.
the result of Go is like "Vmt7?m3M\x00\x00\x00\x00\x00\x00\x00\x00", the 
first 8 bytes is right, the rest 8 bytes is wrong.

Is the "Blowfish.MODE_ECB" parameter in python the key point?
How should blowfish be correctly used?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to