Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char num2char(size_t num){
- char res = 0; int val = num%62;
- if (val<10){ res = val+48;
- }else if (val>=10&&val<36){ res = val+65-10;
- }else if (val>=36&&val<62){ res = val+97-36;
- }return res;
- }
- void swap(char & a, char & b){char t=b;b=a;a=t;}
- void hash(char * src, char * dst, int sz){
- memcpy(dst,src,32);
- static int swap_table[32]={/* shuffled 0 .. 31 */};
- int i; const int maxiter=32;
- for (int iter=0;iter<maxiter;iter++){
- for (i=0;i<32;i++){swap(dst[31-swap_table[i]],dst[swap_table[i]]);}
- for (i=0;i<32;i++){dst[i]+=swap_table[i]-16;}
- for (i=0;i<32;i++){
- dst[i]=num2char(int(dst[i])+
- int(dst[swap_table[i]])+
- 237);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement