如何在nodejs中将大的十六进制值转换为整数?
How to convert big hex value to integer in nodejs?
有一个很大的十六进制值:
var Hex = "ad6eb61316ff805e9c94667ab04aa45aa3203eef71ba8c12afb353a5c7f11657e43f5ce4483d4e6eca46af6b3bde4981499014730d3b233420bf3ecd3287a2768da8bd401f0abd7a5a137d700f0c9d0574ef7ba91328e9a6b055820d03c98d56943139075d";
如何将它转换为 node.js 中的大整数?我试图搜索,但我找到的是
var integer = parseInt(Hex, 16);
但是如果我输入很大的十六进制值,它就不起作用了。我认为。
结果是,
1.1564501846672726e+243
如何才能return正常的大整数?我想在 RSA 加密 中将此值用于 模数。其实我也不知道要不要转换
您需要精确的整数来为 RSA 进行模块化运算,但是 largest integer in JavaScript is 9007199254740991 without losing precision. You cannot represent a larger integer as a Number. You would need to devise a way to do modular arithmetic with many chunks of the large integer or simply use one of the available like the big number arithmetic in JSBN 还提供了 RSA 的完整实现,包括 PKCS#1 v1.5 填充。
有一个很大的十六进制值:
var Hex = "ad6eb61316ff805e9c94667ab04aa45aa3203eef71ba8c12afb353a5c7f11657e43f5ce4483d4e6eca46af6b3bde4981499014730d3b233420bf3ecd3287a2768da8bd401f0abd7a5a137d700f0c9d0574ef7ba91328e9a6b055820d03c98d56943139075d";
如何将它转换为 node.js 中的大整数?我试图搜索,但我找到的是
var integer = parseInt(Hex, 16);
但是如果我输入很大的十六进制值,它就不起作用了。我认为。 结果是,
1.1564501846672726e+243
如何才能return正常的大整数?我想在 RSA 加密 中将此值用于 模数。其实我也不知道要不要转换
您需要精确的整数来为 RSA 进行模块化运算,但是 largest integer in JavaScript is 9007199254740991 without losing precision. You cannot represent a larger integer as a Number. You would need to devise a way to do modular arithmetic with many chunks of the large integer or simply use one of the available like the big number arithmetic in JSBN 还提供了 RSA 的完整实现,包括 PKCS#1 v1.5 填充。