Guest User

BigWookie

a guest
Nov 25th, 2011
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Wertebereiche:
  2. // a,b,c    : [65;90]
  3. // d        : [0;51]
  4. // e        : [0;9999]
  5.  
  6.  
  7. function encryptHash(date, country)
  8. {
  9.     var a = country.charCodeAt(0);
  10.     var b = country.charCodeAt(1);
  11.     var c = country.charCodeAt(2);
  12.  
  13.     var d = parseInt(date.substr(0,2), 10);
  14.     var e = parseInt(date.substr(2,4), 10);
  15.  
  16.     hash = (((a * 91 + b) * 91 + c) * 51 + d) * 2300 + e;
  17.  
  18.     console.log('[Hash  ]'+hash);
  19.     console.log('[Input ]'+ 'a: '+a+', ' +
  20.                             'b: '+b+', ' +
  21.                             'c: '+c+', ' +
  22.                             'd: '+d+', ' +
  23.                             'e: '+e);
  24.  
  25.     return hash;
  26. }
  27.  
  28. function decryptHash(hash)
  29. {
  30.     var tmp = hash;
  31.  
  32.     var e = tmp % 2300;
  33.     tmp = (tmp - e)/2300;
  34.  
  35.     var d = tmp % 51;
  36.     tmp = (tmp - d)/51;
  37.  
  38.     var c = tmp % 91;
  39.     tmp = (tmp - c)/91;
  40.  
  41.     var b = tmp % 91;
  42.     tmp = (tmp - b)/91;
  43.  
  44.     var a = tmp;
  45.    
  46.     console.log('[Output]'+ 'a: '+a+', ' +
  47.                             'b: '+b+', ' +
  48.                             'c: '+c+', ' +
  49.                             'd: '+d+', ' +
  50.                             'e: '+e);
  51.    
  52. }
  53.  
  54. var hash;
  55.  
  56. console.log('Test 1');
  57. hash = encryptHash('222011', 'GER');
  58. decryptHash(hash);
  59.  
  60. // Output 1:
  61. // Test 1
  62. // [Hash  ]69712850211
  63. // [Input ]a: 71, b: 69, c: 82, d: 22, e: 2011
  64. // [Output]a: 71, b: 69, c: 82, d: 22, e: 2011
  65.  
  66. console.log('Test 2');
  67. hash = encryptHash('519999', 'GER');
  68. decryptHash(hash);
  69.  
  70. // Test 2
  71. // [Hash  ]69712924899
  72. // [Input ]a: 71, b: 69, c: 82, d: 51, e: 9999
  73. // [Output]a: 71, b: 69, c: 83, d: 4, e: 799
  74.  
Advertisement
Add Comment
Please, Sign In to add comment