Skating

node v8.17.0
version: 2.0.5
endpointsharetweet
Вычисление контрольной суммы судьи за тур
const hasha = require('hasha'); const algorithm = 'sha1'; const encoding = 'buffer'; // Контрольные примеры WDSF с https://worlddancesport.atlassian.net/wiki/spaces/COSCE/pages/18251778/Scoring+check+sum // Q, T, W // const dances=['171187198','102111175','100127138']; //const dances=['171198187','111102175','100138127']; // В следующем примере неправильный дайжест для W, поэтому контрольная сумма 9977 не совпадает с расчитанной const dances=['1007.518791716.25','1008.51879.51717.25','1008.7517191877.5']; // Q, SF, T, VW, W // Кривощеков https://dance.vftsarr.ru/show_results.php?id=18362&group=10&round=5 //const dances=['56469741863','56464197863','46569741863','56469741863','56469741863']; // Сергеевы https://dance.vftsarr.ru/show_results.php?id=19857&group=15&round=4 //const dances=['22967228233227236','22967227228233236','22967233228227236','22967228227233236','22967228227233236']; let digest; const buffer = []; for (let i = 0; i < dances.length; i += 1) { digest = hasha(dances[i], {encoding, algorithm}); buffer.push(digest) console.log(`Танец ${i+1}: ${ digest.toString('hex') }`); } digest = hasha(buffer,{algorithm}); console.log(`Итоговый ${digest}`); console.log(`Контрольная сумма ${parseInt(digest.substring(digest.length - 4), 16) % 10000}`);
Loading…

no comments

    sign in to comment