728x90
(function(n) {
"use strict";
function xorOperation(a, b) {
return a ^ b;
}
function rotateLeft(x, n) {
return (x << n) | (x >>> (32 - n));
}
function checksumBlock(block, seed) {
var result = seed;
for (var i = 0; i < block.length; i++) {
result = xorOperation(result, block[i]);
result = rotateLeft(result, 5);
}
return result;
}
function stringToBlocks(str) {
var blocks = [];
for (var i = 0; i < str.length; i += 4) {
blocks.push(str.charCodeAt(i) |
(str.charCodeAt(i + 1) << 8) |
(str.charCodeAt(i + 2) << 16) |
(str.charCodeAt(i + 3) << 24));
}
return blocks;
}
function calculateChecksum(str) {
var blocks = stringToBlocks(str);
var seed = 0x12345678;
return checksumBlock(blocks, seed);
}
if (typeof define === "function" && define.amd) {
define(function() { return calculateChecksum; });
} else if (typeof module === "object" && module.exports) {
module.exports = calculateChecksum;
} else {
n.simpleChecksum = calculateChecksum;
}
}(this));
728x90
'호그와트' 카테고리의 다른 글
문크예거 딸의 운전 실력은 어느정도일까 ? (1) | 2024.10.07 |
---|---|
just rolling the dices~~~ (0) | 2024.09.26 |
포ㄹ트를 뽀트르 포트르 포트리스 뽀로로 (0) | 2024.08.18 |
윌의 마음을 이해하는 건 니체를 읽으며 타노스 고기를 뜯어먹을때 온다 (0) | 2024.08.03 |
tryhackme Boiler CTF privilege escalation (0) | 2024.07.27 |