There are lots of algorithm for encoding and decoding . I pick up the most simple one .It is from JavaEE Tutorial 6 . The implementation of codeString in CoderImpl shifts the string argument forward in the alphabet by the number of letters specified in the second argument; any characters that are not letters are left unchanged. (This simple shift code is known as a Caesar cipher, for Julius Caesar, who reportedly used it to communicate with his generals.) I took offset as 4 . data have;
input name $ id $;
cards;
Arthur 1234
Tom 1234
MikeZ 1234
Matt 1234
;
run;
%let offset=4;
data encode;
set have;
do _n_=1 to length(name);
substr(name,_n_,1) = byte(mod(rank(char(name,_n_))+&offset,255)) ;
end;
run;
data decode;
set encode;
do _n_=1 to length(name);
substr(name,_n_,1) =byte(mod(rank(char(name,_n_))-&offset+255,255));
end;
run;
Ksharp
... View more