MCPcopy Index your code
hub / github.com/dmarman/sha256algorithm / stringToBinary

Function stringToBinary

src/classes/utils.js:1–11  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

1export function stringToBinary(string) {
2 const encoder = new TextEncoder();
3 const byteArray = encoder.encode(string);
4 let result = [];
5
6 byteArray.forEach((value) => {
7 result.push(decimalToBinary(value).padStart(8, '0'));
8 });
9
10 return result.join('')
11}
12
13export function hexToBinary(hex) {
14 let decimal = chunkString(hex, 2).map(value => parseInt(value, 16));

Callers 3

onInputBaseChangeFunction · 0.90
paddingFunction · 0.70
paddingExplainedFunction · 0.70

Calls 1

decimalToBinaryFunction · 0.70

Tested by

no test coverage detected