MCPcopy
hub / github.com/gchq/CyberChef / readString

Method readString

src/core/lib/Stream.mjs:65–79  ·  view source on GitHub ↗

* Interpret the following bytes as a string, stopping at the next null byte or * the supplied limit. * * @param {number} [numBytes=-1] * @returns {string}

(numBytes=-1)

Source from the content-addressed store, hash-verified

63 * @returns {string}
64 */
65 readString(numBytes=-1) {
66 if (this.position > this.length) return undefined;
67
68 if (numBytes === -1) numBytes = this.length - this.position;
69
70 let result = "";
71 for (let i = this.position; i < this.position + numBytes; i++) {
72 const currentByte = this.bytes[i];
73 if (currentByte === 0) break;
74 result += String.fromCharCode(currentByte);
75 }
76 this.position += numBytes;
77 this.bitPos = 0;
78 return result;
79 }
80
81 /**
82 * Interpret the following bytes as an integer in big or little endian.

Callers 4

extractPNGFunction · 0.95
runMethod · 0.95
runMethod · 0.95
runMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected