Skip to content

Instantly share code, notes, and snippets.

@elmariachi111
Created March 19, 2021 17:16
Show Gist options
  • Save elmariachi111/60c399976d6f3baff987449aea37c486 to your computer and use it in GitHub Desktop.
Save elmariachi111/60c399976d6f3baff987449aea37c486 to your computer and use it in GitHub Desktop.
test squares
const inp = 'b44861ea32a51020';
console.log(inp);
const square0 = Square.fromBytes(Buffer.from(inp, 'hex'));
Square.print(square0);
const bits = Square.toBinArray(square0);
console.log(bits);
const bytes = Square.bitsToBytes(bits);
console.log(bytes.toString("hex"));
//const square1 = Square.fromBytes(randBuffer(8));
const squareRand = Square.fromBytes(randBuffer(8));
//const square3 = Square.fromBytes(Buffer.from('0000ABCDDDAB0000', 'hex'));
const mx1 =
`10000001
01000010
00111100
00100100
00100100
00111100
01000010
10000001`
const mx2 =
`01010101
10101010
01010101
10101010
01010101
10101010
01010101
10101010`
const mx3 =
`01100110
10011001
10011001
01100110
01100110
10011001
10011001
01100110`
const mx4=
`00010000
00010000
00010000
00010000
00010000
00010000
00010000
00010000`
const mx5=
`00000000
00000000
00000000
00000000
11111111
00000000
00000000
0000000`
const square1 = Square.fromText(mx1);
const square2 = Square.fromText(mx2);
const square3 = Square.fromText(mx3);
const sq4 = Square.fromText(mx4);
const sq5 = Square.fromText(mx5);
Square.print(sq4);
Square.print(sq5);
Square.print(Square.operate([sq4,sq5], Square.or))
// Square.print(square1);
// console.log(Square.entropy(square1));
//console.log(Square.toBinArray(square1))
Square.print(squareRand);
console.log(Square.entropy(squareRand));
const binArray = Square.toBinArray(squareRand);
console.log(binArray);
const hx = Square.bitsToBytes(binArray);
console.log(hx.toString("hex"));
Square.print(square1);
console.log(Square.entropy(square1));
Square.print(square2);
console.log(Square.entropy(square2));
Square.print(square3);
console.log(Square.entropy(square3));
// const combined = Square.operate([square1, square2], Square.xor);
// Square.print(combined);
// console.log(Square.toBinArray(combined))
// const c2 = Square.operate([combined, square2], Square.or);
// Square.print(c2);
// console.log(Square.toBinArray(c2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment