PHP checksum working need to refactor and make more useful, easier to use, refactor lots of code

This commit is contained in:
Hash Borgir
2022-06-22 01:47:49 -06:00
parent 69d4728d8c
commit 3b03e54fa5
2 changed files with 11 additions and 9 deletions

View File

@@ -87,10 +87,14 @@ function setBit(int $n, int $p, bool $b){
function getBit(int $b, int $p){
return intval(($b & (1 << $p)) !== 0);
}
function checksum($fileData) {
/**
* Calculate D2S Checksum
* @param $data
* @return string
*/
function checksum($data) : string {
$nSignature = 0;
foreach($fileData as $byte){
foreach($data as $byte){
$nSignature = ((($nSignature << 1) | ($nSignature >> 31)) + $byte) & 0xFFFFFFFF;
}
return swapEndianness(dechex($nSignature));