Advertisement
Guest User

Untitled

a guest
May 24th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. char num2char(size_t num){
  2. char res = 0; int val = num%62;
  3. if (val<10){ res = val+48;
  4. }else if (val>=10&&val<36){ res = val+65-10;
  5. }else if (val>=36&&val<62){ res = val+97-36;
  6. }return res;
  7. }
  8. void swap(char & a, char & b){char t=b;b=a;a=t;}
  9. void hash(char * src, char * dst, int sz){
  10. memcpy(dst,src,32);
  11. static int swap_table[32]={/* shuffled 0 .. 31 */};
  12. int i; const int maxiter=32;
  13. for (int iter=0;iter<maxiter;iter++){
  14. for (i=0;i<32;i++){swap(dst[31-swap_table[i]],dst[swap_table[i]]);}
  15. for (i=0;i<32;i++){dst[i]+=swap_table[i]-16;}
  16. for (i=0;i<32;i++){
  17. dst[i]=num2char(int(dst[i])+
  18. int(dst[swap_table[i]])+
  19. 237);
  20. }
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement