hxnodejs
hxnodejs copied to clipboard
Nodejs crypto methods
Imho crypto methods provided by nodejs should be used instead of the haxe(js) implementation. I guess they are faster and probably less error prone.
For haxe.crypto.Md5 this would look like:
package haxe.crypto;
import js.node.Crypto;
import haxe.io.Bytes;
class Md5 {
public static function encode( s : String ) : String {
var h = Crypto.createHash( "md5" );
h.update( s );
return h.digest( "hex" );
}
public static function make( b : Bytes ) : Bytes {
var h = Crypto.createHash( "md5" );
h.update( b.getData() );
return Bytes.ofData( h.digest() );
}
}
What do you think?
Don't know the internals of Haxe's way. But I think if the interface is the same we could be ok with that!
PR's welcome, but I'd like to see some comparison measurements
I think there's the same problem problem with this as described in #42