Skip to content

Commit

Permalink
Correction of problem with the truncate binary method
Browse files Browse the repository at this point in the history
  • Loading branch information
SteezCram committed Jul 30, 2020
1 parent fe5c2fb commit 510a96c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
6 changes: 4 additions & 2 deletions Byte/fn_codePointToByte.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,17 @@ _binaryToDecimal = {
_truncateBinary = {
params [["_b", [], [[]]]];

_returnB = +_b;

// Truncate the array
for "_i" from 0 to count(_b) - 1 do {
if ((_b # _i) isEqualTo 0) then {
_b deleteAt _i;
_returnB deleteAt 0;
};
if ((_b # _i) isEqualTo 1) exitWith {};
};

_b;
_returnB;
};

// Bitwise functions
Expand Down
6 changes: 4 additions & 2 deletions Byte/fn_truncateBinary.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@

params [["_b", [], [[]]]];

_returnB = +_b;

// Truncate the array
for "_i" from 0 to count(_b) - 1 do {
if ((_b # _i) isEqualTo 0) then {
_b deleteAt _i;
_returnB deleteAt 0;
};
if ((_b # _i) isEqualTo 1) exitWith {};
};

_b;
_returnB;
12 changes: 8 additions & 4 deletions Encryption/fn_arcfour.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,17 @@ _codePointToByte = {
_truncateBinary = {
params [["_b", [], [[]]]];

_returnB = +_b;

// Truncate the array
for "_i" from 0 to count(_b) - 1 do {
if ((_b # _i) isEqualTo 0) then {
_b deleteAt _i;
_returnB deleteAt 0;
};
if ((_b # _i) isEqualTo 1) exitWith {};
};

_b;
_returnB;
};

// Bitwise functions
Expand Down Expand Up @@ -221,15 +223,17 @@ _binaryToDecimal = {
_truncateBinary = {
params [["_b", [], [[]]]];

_returnB = +_b;

// Truncate the array
for "_i" from 0 to count(_b) - 1 do {
if ((_b # _i) isEqualTo 0) then {
_b deleteAt _i;
_returnB deleteAt 0;
};
if ((_b # _i) isEqualTo 1) exitWith {};
};

_b;
_returnB;
};
_bitwiseXor = {
params [["_x", [], [[]]], ["_y", [], [[]]], ["_bits", 0, [0]]];
Expand Down

0 comments on commit 510a96c

Please sign in to comment.