mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-10 08:15:00 -04:00
Stream logging
This commit is contained in:
parent
6e75ba3f7d
commit
41a080aee1
1 changed files with 23 additions and 1 deletions
|
@ -105,25 +105,47 @@ export default class Stream {
|
||||||
bitBufLen = 0;
|
bitBufLen = 0;
|
||||||
|
|
||||||
// Add remaining bits from current byte
|
// Add remaining bits from current byte
|
||||||
|
console.log("Bit pos: " + this.bitPos.toString(2));
|
||||||
|
console.log("Pos: " + this.position.toString(2));
|
||||||
|
|
||||||
bitBuf = (this.bytes[this.position++] & bitMask(this.bitPos)) >>> this.bitPos;
|
bitBuf = (this.bytes[this.position++] & bitMask(this.bitPos)) >>> this.bitPos;
|
||||||
bitBufLen = 8 - this.bitPos;
|
bitBufLen = 8 - this.bitPos;
|
||||||
this.bitPos = 0;
|
this.bitPos = 0;
|
||||||
|
|
||||||
|
console.log("Bit pos: " + this.bitPos.toString(2));
|
||||||
|
console.log("Bit buff: " + bitBuf.toString(2));
|
||||||
|
console.log("Bit buff len: " + bitBufLen.toString(2));
|
||||||
|
console.log("Num bits: " + numBits.toString(2));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Not enough bits yet
|
// Not enough bits yet
|
||||||
while (bitBufLen < numBits) {
|
while (bitBufLen < numBits) {
|
||||||
bitBuf |= this.bytes[this.position++] << bitBufLen;
|
bitBuf |= this.bytes[this.position++] << bitBufLen;
|
||||||
bitBufLen += 8;
|
bitBufLen += 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("Pos: " + this.position.toString(2));
|
||||||
|
|
||||||
// Reverse back to numBits
|
// Reverse back to numBits
|
||||||
if (bitBufLen > numBits) {
|
if (bitBufLen > numBits) {
|
||||||
|
|
||||||
const excess = bitBufLen - numBits;
|
const excess = bitBufLen - numBits;
|
||||||
bitBuf &= (1 << numBits) - 1;
|
console.log("Excess: " + excess.toString(2));
|
||||||
|
console.log("Bit buff: " + bitBuf.toString(2));
|
||||||
|
console.log("Mask: " + ((1 << numBits) - 1).toString(2));
|
||||||
|
//bitBuf &= (1 << numBits) - 1;
|
||||||
|
bitBuf &= 256 - (1 << numBits);
|
||||||
|
bitBuf = bitBuf >> excess;
|
||||||
bitBufLen -= excess;
|
bitBufLen -= excess;
|
||||||
this.position--;
|
this.position--;
|
||||||
this.bitPos = 8 - excess;
|
this.bitPos = 8 - excess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("Bit buff len: " + bitBufLen.toString(2));
|
||||||
|
console.log("Bit buff: " + bitBuf.toString(2));
|
||||||
|
console.log("Pos: " + this.position.toString(2));
|
||||||
|
|
||||||
return bitBuf;
|
return bitBuf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue