gpt4 book ai didi

sas - md5 函数用于合并数据集是否安全?

转载 作者:行者123 更新时间:2023-12-01 11:35:02 25 4
gpt4 key购买 nike

我们即将推广一段代码,它使用 SAS md5() 哈希函数来有效地跟踪大型数据集中的变化。

format md5 $hex32.;
md5=md5(cats(of _all_));

根据 documentation :

The MD5 function converts a string, based on the MD5 algorithm, into a 128-bit hash value. This hash value is referred to as a message digest (digital signature), which is nearly unique for each string that is passed to the function.

“几乎独一无二”大约在什么阶段开始构成数据完整性风险(如果有的话)?

最佳答案

我见过一个md5比较出错的例子。如果第一行(两列)的值是“AB”和“CD”,第二行的值是“ABC”和“D”,则它们具有相同的 md5 值。看这个例子:

data md5;
attrib a b length=$3 informat=$3.;
infile datalines;
input a b;
format md5 $hex32.;
md5=md5(cats(of _all_));
datalines;
AB CD
A BCD
;run;

当然,这是因为 CATS(属于 _all_)将连接并剥离变量(使用“最佳”格式将数字转换为字符串),没有分隔符。如果您改为使用 CAT,则不会发生这种情况,因为不会删除前导和尾随空白。这个错误不是很牵强。如果您有缺失值,那么这种情况可能会更频繁地发生。例如,如果您在文本变量中有很多二进制值,其中一些缺失,则这种情况可能会经常发生。

可以手动执行此操作,在值之间添加分隔符。当然,当你有 ("AB!"和 "CD") 和 ("AB"和 "!CD") 并且你使用 "!"时,你仍然会遇到这种情况。作为分隔符...

关于sas - md5 函数用于合并数据集是否安全?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27906683/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com