我想使用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_=2I 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=64489C85DC2FE0787B85CD87214B3810Note:
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.
更多推荐
发布评论