Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -export([zxor/2]).
- zxor(Bin1,Bin2)->
- Len1=erlang:byte_size(Bin1),
- Len2=erlang:byte_size(Bin2),
- {B1,B2}= if
- (Len1<Len2)->{bin_pad(Bin1, Len2-Len1),Bin2};
- (Len1>Len2)->{Bin1,bin_pad(Bin2, Len1-Len2)};
- true ->{Bin1,Bin2}
- end,
- crypto:exor(B1,B2).
- bin_pad(Bin,Len)->bin_pad(Bin,Len,<<16#00>>).
- bin_pad(Bin,0,_Ch)->Bin;
- bin_pad(Bin,Len,Ch)->
- L=binary:copy(Ch, Len),
- <<Bin/binary,L/binary>>.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement