SAS MD5 Hashing(SAS MD5 Hashing)

编程入门 行业动态 更新时间:2024-10-23 07:26:18
SAS MD5 Hashing(SAS MD5 Hashing)

我想使用MD5在我的SAS数据集中散列敏感信息(1个字段)。 但是在散列之后,数据看起来很尴尬,即所有特殊字符。 这是使用哈希函数的正确方法吗?

我的代码:

data md5; set sashelp.class (obs=2); md5 = md5(strip(name)); keep name md5; put _all_; run;

我的输出:

Name=Alfred Sex=M Age=14 Height=69 Weight=112.5 md5=�p?ޞ��\�rT]( _ERROR_=0 _N_=1 Name=Alice Sex=F Age=13 Height=56.5 Weight=84 md5=dH���/�x{�͇!K8 _ERROR_=0 _N_=2

I want to hash sensitive information (1 field) in my SAS data set using MD5. But after hashing the data looks awkward, i.e. all special characters. Is this the right way to use a hash function?

My Code:

data md5; set sashelp.class (obs=2); md5 = md5(strip(name)); keep name md5; put _all_; run;

My Output:

Name=Alfred Sex=M Age=14 Height=69 Weight=112.5 md5=�p?ޞ��\�rT]( _ERROR_=0 _N_=1 Name=Alice Sex=F Age=13 Height=56.5 Weight=84 md5=dH���/�x{�͇!K8 _ERROR_=0 _N_=2

最满意答案

这是正确的,你只需要应用十六进制格式$hex32. 所以它是可读的。 MD5是128位哈希,但有一个更好的哈希称为SHA256() ,它是256位哈希。

码:

data md5; set sashelp.class (obs=2); format md5 $hex32.; md5 = md5(strip(name)); keep name md5; put _all_; run;

输出:

Name=Alfred md5=86703FDE9E87DD5C0F8E1072545D0128 Name=Alice md5=64489C85DC2FE0787B85CD87214B3810

注意:

您还可以在字符串中添加SALT或PEPPER值以增加安全性; 这些字符串连接到字符串的开头或结尾。

That's correct, you just need to apply a hexadecimal format $hex32. so it's readable. MD5 is 128-bit Hash but there's a better hashing called SHA256() which is 256-bit hash.

Code:

data md5; set sashelp.class (obs=2); format md5 $hex32.; md5 = md5(strip(name)); keep name md5; put _all_; run;

Output:

Name=Alfred md5=86703FDE9E87DD5C0F8E1072545D0128 Name=Alice md5=64489C85DC2FE0787B85CD87214B3810

Note:

You can also add a SALT or PEPPER values to your string for added security; These are string concatenate to the beginning or end of your string.

更多推荐

本文发布于:2023-07-20 02:58:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1192104.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:SAS   Hashing

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!