Javascript。将MD5哈希转换为整数。

时间:2022-09-09 12:37:51

Is it possible in Javascript to convert something like this: d131dd02c5e6eec4 693d9a0698aff95c 2fcab58712467eab 4004583eb8fb7f89, which is the result of an MD5 hash function, into an integer ?

在Javascript中是否可能转换成这样的东西:d131dd02c5e6eec4 693d9a0698aff95c 2fcab58712467eab 4004583eb8fb7f89,这是MD5哈希函数的结果,是一个整数?

2 个解决方案

#1


3  

That looks like a hexadecimal number, so you could try using the parseInt function and pass in a base of sixteen:

这看起来像一个十六进制数,所以你可以尝试使用parseInt函数并在16的基础上传递:

var num = parseInt(string, 16);

Edit: This method doesn't actually work. See the comments for details.

编辑:这个方法实际上并不起作用。详见注释。

#2


0  

Maybe this one https://github.com/lovell/farmhash ?

也许这一个是https://github.com/lovell/farmhash ?

const farmhash = require('farmhash');
const hexDigest = crypto.createHash('md5').update().digest('hex');
farmhash.fingerprint64(hexDigest);

#1


3  

That looks like a hexadecimal number, so you could try using the parseInt function and pass in a base of sixteen:

这看起来像一个十六进制数,所以你可以尝试使用parseInt函数并在16的基础上传递:

var num = parseInt(string, 16);

Edit: This method doesn't actually work. See the comments for details.

编辑:这个方法实际上并不起作用。详见注释。

#2


0  

Maybe this one https://github.com/lovell/farmhash ?

也许这一个是https://github.com/lovell/farmhash ?

const farmhash = require('farmhash');
const hexDigest = crypto.createHash('md5').update().digest('hex');
farmhash.fingerprint64(hexDigest);