MCPcopy Create free account
hub / github.com/TheAlgorithms/JavaScript / u8ToU32

Function u8ToU32

Hashes/MD5.js:64–77  ·  view source on GitHub ↗

* Converts Uint8Array to Uint32Array * * @param {Uint8Array} u8Array Uint8Array to convert * @returns {Uint32Array} - Required Uint32Array

(u8Array)

Source from the content-addressed store, hash-verified

62 * @returns {Uint32Array} - Required Uint32Array
63 */
64function u8ToU32(u8Array) {
65 const uint32Array = new Uint32Array(u8Array.length / 4)
66
67 for (let i = 0; i < u8Array.length; i += 4) {
68 uint32Array[i / 4] =
69 (u8Array[i] |
70 (u8Array[i + 1] << 8) |
71 (u8Array[i + 2] << 16) |
72 (u8Array[i + 3] << 24)) >>>
73 0
74 }
75
76 return uint32Array
77}
78
79/**
80 * Converts Uint32Array to Uint8Array

Callers 1

preProcessFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected