brix / crypto-js

JavaScript library of crypto standards.
Other
15.88k stars 2.39k forks source link

Assistance with conversion from crypto module to crypto-js module #400

Open ugobey opened 2 years ago

ugobey commented 2 years ago

Hi there.

I was using the built in NodeJS crypto module but it's not supported in versions less than 14 of Node so I prefer to use your module.

I am having issues understanding how I convert this function to work the same in your module.

function toHash(csUUID) {
    const hash = crypto.createHash("sha256");
    hash.update(utf8.encode(csUUID));
    const resAsBuff = hash.digest().slice(0, 8);
    return resAsBuff.readBigUInt64BE().toString(10);
}

var hashedUID = toHash(csUUID);

Thanks!

gjfei commented 1 year ago

Hi there.

I was using the built in NodeJS crypto module but it's not supported in versions less than 14 of Node so I prefer to use your module.

I am having issues understanding how I convert this function to work the same in your module.

function toHash(csUUID) {
    const hash = crypto.createHash("sha256");
    hash.update(utf8.encode(csUUID));
    const resAsBuff = hash.digest().slice(0, 8);
    return resAsBuff.readBigUInt64BE().toString(10);
}

var hashedUID = toHash(csUUID);

Thanks!

I also met this problem. Have you solved it

ugobey commented 1 year ago

No I just upgraded node