haxe MD5 wrong on flash platform

I try to get base64 encoded md5 hashed password with salt (salt is md5, I got base64 encoded)

var pass = "hello";
var salt=haxe.crypto.Base64.encode(haxe.crypto.Md5.make(haxe.io.Bytes.ofString("hello")));
    trace(haxe.crypto.Base64.encode(haxe.crypto.Md5.make(haxe.io.Bytes.ofString(haxe.crypto.Base64.decode(salt).toString() + haxe.crypto.Md5.make(haxe.io.Bytes.ofString(pass)).toString()))));

on neko it writes:

YWsigXuA7tn2XDqjjNKQVA==

but flash give me:

9Hpay/lKyMcm/s8qpPRczQ==

why they are different? and how I can solve this?

Upvotes: 1

Views: 165

Answers (1)

This solve the problem

var buf:Bytes = Bytes.ofString("aaaaaaaaaaaaaaaabbbbbbbbbbbbbbbb"); //create Bytes 32 long 
buf.blit(0, Base64.decode(salt), 0, 16); //set first 16 
buf.blit(16, Md5.make(Bytes.ofString(pass)), 0, 16); //set second 16
var password:String = Base64.encode(Md5.make(buf));//md5(salt+pass)

Upvotes: 1

Related Questions