Dear SAS Communities Members:
Following SAS code encrypts Make and Model well. How can I apply Decryption to create Make_R and Mode_R variables from encrypted HASH field ?
( P.S. I don't want to use MD5 encryption.)
data cars;
length hash $ 32;
format hash $hex64.;
set sashelp.cars;
hash = sha256(cats(make,model));
run;
OR
I have alphanumeric variable and numeric variable.
How can I encrypt and decrypt them without using MD5.
I have an alphanumeric variable and numeric variables.
How can I encrypt and decrypt them without using MD5.
Data a;
input ID $ dept SALARY;
cards;
ABC123 10020 45000
;
RUN;
Both SHA256 and MD5 are hashing algorithms, not encrypting algorithms. They produce the same length of key, regardless of the input. The source could be a single word, or the combined works of William Shakespeare. There is no way of decrypting them, only of finding a string that incidentally results in the same hash. How much computing power you need to find such a value is a measure for the quality of the hash.
To get the original values back from such a hash, you need to keep a lookup table with original value and hash.
The SAS-supplied hashing algorithms SHA256 and MD5 are for one-way encryption with no (easy) means of decryption. They rely on you retaining the original unencrypted version of your data.
If your use case is to exchange encrypted SAS data with other parties that can easily be decrypted then I suggest using tools like 7-zip where you do file or folder password-secured encryption / decryption.
Both SHA256 and MD5 are hashing algorithms, not encrypting algorithms. They produce the same length of key, regardless of the input. The source could be a single word, or the combined works of William Shakespeare. There is no way of decrypting them, only of finding a string that incidentally results in the same hash. How much computing power you need to find such a value is a measure for the quality of the hash.
To get the original values back from such a hash, you need to keep a lookup table with original value and hash.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.