Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Wertebereiche:
- // a,b,c : [65;90]
- // d : [0;51]
- // e : [0;9999]
- function encryptHash(date, country)
- {
- var a = country.charCodeAt(0);
- var b = country.charCodeAt(1);
- var c = country.charCodeAt(2);
- var d = parseInt(date.substr(0,2), 10);
- var e = parseInt(date.substr(2,4), 10);
- hash = (((a * 91 + b) * 91 + c) * 51 + d) * 2300 + e;
- console.log('[Hash ]'+hash);
- console.log('[Input ]'+ 'a: '+a+', ' +
- 'b: '+b+', ' +
- 'c: '+c+', ' +
- 'd: '+d+', ' +
- 'e: '+e);
- return hash;
- }
- function decryptHash(hash)
- {
- var tmp = hash;
- var e = tmp % 2300;
- tmp = (tmp - e)/2300;
- var d = tmp % 51;
- tmp = (tmp - d)/51;
- var c = tmp % 91;
- tmp = (tmp - c)/91;
- var b = tmp % 91;
- tmp = (tmp - b)/91;
- var a = tmp;
- console.log('[Output]'+ 'a: '+a+', ' +
- 'b: '+b+', ' +
- 'c: '+c+', ' +
- 'd: '+d+', ' +
- 'e: '+e);
- }
- var hash;
- console.log('Test 1');
- hash = encryptHash('222011', 'GER');
- decryptHash(hash);
- // Output 1:
- // Test 1
- // [Hash ]69712850211
- // [Input ]a: 71, b: 69, c: 82, d: 22, e: 2011
- // [Output]a: 71, b: 69, c: 82, d: 22, e: 2011
- console.log('Test 2');
- hash = encryptHash('519999', 'GER');
- decryptHash(hash);
- // Test 2
- // [Hash ]69712924899
- // [Input ]a: 71, b: 69, c: 82, d: 51, e: 9999
- // [Output]a: 71, b: 69, c: 83, d: 4, e: 799
Advertisement
Add Comment
Please, Sign In to add comment