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

Method arrayBufferToStr

src/core/Utils.mjs:693–698  ·  view source on GitHub ↗

* Converts an ArrayBuffer to a string. * * @param {ArrayBuffer} arrayBuffer * @param {boolean} [utf8=true] - Whether to attempt to decode the buffer as UTF-8 * @returns {string} * * @example * // returns "hello" * Utils.arrayBufferToStr(Uint8Array.from([104,10

(arrayBuffer, utf8=true)

Source from the content-addressed store, hash-verified

691 * Utils.arrayBufferToStr(Uint8Array.from([104,101,108,108,111]).buffer);
692 */
693 static arrayBufferToStr(arrayBuffer, utf8=true) {
694 log.debug(`Converting array buffer[${arrayBuffer?.byteLength}] to str`);
695 if (!arrayBuffer || !arrayBuffer.byteLength) return "";
696 const arr = new Uint8Array(arrayBuffer);
697 return utf8 ? Utils.byteArrayToUtf8(arr) : Utils.byteArrayToChars(arr);
698 }
699
700 /**
701 * Calculates the Shannon entropy for a given set of data.

Callers 15

formatContentMethod · 0.80
fromArrayBufferMethod · 0.80
fromArrayBufferMethod · 0.80
fromArrayBufferMethod · 0.80
fromArrayBufferMethod · 0.80
constructorMethod · 0.80
outputCheckPassesMethod · 0.80
runHashFunction · 0.80
sm3Method · 0.80
runMethod · 0.80
runMethod · 0.80
runMethod · 0.80

Calls 2

byteArrayToUtf8Method · 0.80
byteArrayToCharsMethod · 0.80

Tested by

no test coverage detected