hxnodejs icon indicating copy to clipboard operation
hxnodejs copied to clipboard

Nodejs crypto methods

Open tong opened this issue 9 years ago • 3 comments

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?

tong avatar Oct 02 '15 13:10 tong

Don't know the internals of Haxe's way. But I think if the interface is the same we could be ok with that!

eduardo-costa avatar Oct 02 '15 13:10 eduardo-costa

PR's welcome, but I'd like to see some comparison measurements

nadako avatar Nov 04 '15 20:11 nadako

I think there's the same problem problem with this as described in #42

nadako avatar Nov 09 '15 12:11 nadako