在R中将md5哈希转换为bigint

在R中将md5哈希转换为bigint,r,hash,md5,digest,R,Hash,Md5,Digest,我想知道如何将md5哈希转换为大整数,以便对其应用模运算符 我使用摘要库创建哈希: h <- digest("luca", algo="md5", ascii=TRUE, raw=TRUE) > h [1] 18 0e 41 2e 42 db 5a 8c 45 3c 8a 81 c5 90 4e 5b h [1] 18 0e 41 2e 42 db 5a 8c 45 3c 8a 81 c5 90 4e 5b 现在,我想将h转换为一个大整数,并能够对其应用模运算符(%%) 我如何才

我想知道如何将md5哈希转换为大整数,以便对其应用模运算符

我使用
摘要
库创建哈希:

h <- digest("luca", algo="md5", ascii=TRUE, raw=TRUE)
> h
[1] 18 0e 41 2e 42 db 5a 8c 45 3c 8a 81 c5 90 4e 5b
h
[1] 18 0e 41 2e 42 db 5a 8c 45 3c 8a 81 c5 90 4e 5b
现在,我想将
h
转换为一个大整数,并能够对其应用模运算符(
%%

我如何才能做到这一点?

使用Rmpfr库1,以下工作:

# Get a hex string of the MD5 hash:
h = digest("luca", algo="md5", ascii = TRUE, raw = FALSE)
result = mpfr(h, base = 16)
result
# 1 'mpfr' number of precision  128   bits
# [1] 31975486076668374554448903959384968795

result %% 1024
# 1 'mpfr' number of precision  128   bits
# [1] 603


1要安装Rmpfr,需要安装其依赖项GNU mpfr库。有关更多信息,请参阅评论。

它工作正常!谢谢!对于那些拥有issuer安装Rmpfr的用户,您需要libmpfr-dev库。在像Ubuntu这样的系统中,您可以使用:sudo apt get install libmpfr dev安装它,然后使用:install.packages(“Rmpfr”)在R中安装Rmpfr。此外,您还可以通过请求digest生成字符串来跳过粘贴步骤:h@lucacerone Cool。因为这两个都是有价值的评论,我将把它们直接放到答案中,让其他用户更容易看到它们。