-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
78ec864
commit e22b097
Showing
14 changed files
with
249 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
**/** | ||
!**/*.js | ||
!**/*.ts | ||
* | ||
!*.js | ||
!*.ts | ||
.git | ||
.vscode | ||
cjs | ||
dist | ||
esm | ||
types | ||
!src | ||
!test | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,27 @@ | ||
import { _internal } from "."; | ||
|
||
/** Adds the given key to each byte of the given data. */ | ||
function add(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number, encoding: string): string; | ||
function add(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number): Uint8Array; | ||
function add(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number, encoding?: string): string | Uint8Array { | ||
function add( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number, | ||
encoding: string | ||
): string; | ||
function add( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number | ||
): Uint8Array; | ||
function add( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number, | ||
encoding?: string | ||
): string | Uint8Array { | ||
const k = !isNaN(key) ? Number(key) : 0; | ||
const result = _internal.toBuffer(data).map(x => x + k & 255); | ||
return encoding ? ((typeof Buffer != "undefined" && Buffer.isBuffer(result)) ? | ||
result.toString(encoding as BufferEncoding) : new TextDecoder(encoding).decode(result)) : result; | ||
const result = _internal.toBuffer(data).map(x => (x + k) & 255); | ||
return encoding | ||
? typeof Buffer != "undefined" && Buffer.isBuffer(result) | ||
? result.toString(encoding as BufferEncoding) | ||
: new TextDecoder(encoding).decode(result) | ||
: result; | ||
} | ||
|
||
export = add; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,27 @@ | ||
import { _internal } from "."; | ||
|
||
/** Performs a bitwise AND operation on each byte of the given data using the given key. */ | ||
function and(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number, encoding: string): string; | ||
function and(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number): Uint8Array; | ||
function and(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number, encoding?: string): string | Uint8Array { | ||
function and( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number, | ||
encoding: string | ||
): string; | ||
function and( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number | ||
): Uint8Array; | ||
function and( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number, | ||
encoding?: string | ||
): string | Uint8Array { | ||
const k = !isNaN(key) ? Number(key) : 0; | ||
const result = _internal.toBuffer(data).map(x => x & k & 255); | ||
return encoding ? ((typeof Buffer != "undefined" && Buffer.isBuffer(result)) ? | ||
result.toString(encoding as BufferEncoding) : new TextDecoder(encoding).decode(result)) : result; | ||
return encoding | ||
? typeof Buffer != "undefined" && Buffer.isBuffer(result) | ||
? result.toString(encoding as BufferEncoding) | ||
: new TextDecoder(encoding).decode(result) | ||
: result; | ||
} | ||
|
||
export = and; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,27 @@ | ||
import { _internal } from "."; | ||
|
||
/** Divides each byte of the given data by the given key. */ | ||
function divide(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number, encoding: string): string; | ||
function divide(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number): Uint8Array; | ||
function divide(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number, encoding?: string): string | Uint8Array { | ||
function divide( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number, | ||
encoding: string | ||
): string; | ||
function divide( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number | ||
): Uint8Array; | ||
function divide( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number, | ||
encoding?: string | ||
): string | Uint8Array { | ||
const k = !isNaN(key) ? Number(key) : 0; | ||
const result = _internal.toBuffer(data).map(x => x / k & 255); | ||
return encoding ? ((typeof Buffer != "undefined" && Buffer.isBuffer(result)) ? | ||
result.toString(encoding as BufferEncoding) : new TextDecoder(encoding).decode(result)) : result; | ||
const result = _internal.toBuffer(data).map(x => (x / k) & 255); | ||
return encoding | ||
? typeof Buffer != "undefined" && Buffer.isBuffer(result) | ||
? result.toString(encoding as BufferEncoding) | ||
: new TextDecoder(encoding).decode(result) | ||
: result; | ||
} | ||
|
||
export = divide; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,27 @@ | ||
import { _internal } from "."; | ||
|
||
/** Multiplies each byte of the given data by the given key. */ | ||
function multiply(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number, encoding: string): string; | ||
function multiply(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number): Uint8Array; | ||
function multiply(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number, encoding?: string): string | Uint8Array { | ||
function multiply( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number, | ||
encoding: string | ||
): string; | ||
function multiply( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number | ||
): Uint8Array; | ||
function multiply( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number, | ||
encoding?: string | ||
): string | Uint8Array { | ||
const k = !isNaN(key) ? Number(key) : 0; | ||
const result = _internal.toBuffer(data).map(x => x * k & 255); | ||
return encoding ? ((typeof Buffer != "undefined" && Buffer.isBuffer(result)) ? | ||
result.toString(encoding as BufferEncoding) : new TextDecoder(encoding).decode(result)) : result; | ||
const result = _internal.toBuffer(data).map(x => (x * k) & 255); | ||
return encoding | ||
? typeof Buffer != "undefined" && Buffer.isBuffer(result) | ||
? result.toString(encoding as BufferEncoding) | ||
: new TextDecoder(encoding).decode(result) | ||
: result; | ||
} | ||
|
||
export = multiply; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,27 @@ | ||
import { _internal } from "."; | ||
|
||
/** Performs a bitwise NAND operation on each byte of the given data using the given key. */ | ||
function nand(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number, encoding: string): string; | ||
function nand(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number): Uint8Array; | ||
function nand(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number, encoding?: string): string | Uint8Array { | ||
function nand( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number, | ||
encoding: string | ||
): string; | ||
function nand( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number | ||
): Uint8Array; | ||
function nand( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number, | ||
encoding?: string | ||
): string | Uint8Array { | ||
const k = !isNaN(key) ? Number(key) : 0; | ||
const result = _internal.toBuffer(data).map(x => (x & k & 255) ^ 255); | ||
return encoding ? ((typeof Buffer != "undefined" && Buffer.isBuffer(result)) ? | ||
result.toString(encoding as BufferEncoding) : new TextDecoder(encoding).decode(result)) : result; | ||
return encoding | ||
? typeof Buffer != "undefined" && Buffer.isBuffer(result) | ||
? result.toString(encoding as BufferEncoding) | ||
: new TextDecoder(encoding).decode(result) | ||
: result; | ||
} | ||
|
||
export = nand; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,27 @@ | ||
import { _internal } from "."; | ||
|
||
/** Performs a bitwise NOR operation on each byte of the given data using the given key. */ | ||
function nor(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number, encoding: string): string; | ||
function nor(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number): Uint8Array; | ||
function nor(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number, encoding?: string): string | Uint8Array { | ||
function nor( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number, | ||
encoding: string | ||
): string; | ||
function nor( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number | ||
): Uint8Array; | ||
function nor( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number, | ||
encoding?: string | ||
): string | Uint8Array { | ||
const k = !isNaN(key) ? Number(key) : 0; | ||
const result = _internal.toBuffer(data).map(x => (x | k & 255) ^ 255); | ||
return encoding ? ((typeof Buffer != "undefined" && Buffer.isBuffer(result)) ? | ||
result.toString(encoding as BufferEncoding) : new TextDecoder(encoding).decode(result)) : result; | ||
const result = _internal.toBuffer(data).map(x => (x | (k & 255)) ^ 255); | ||
return encoding | ||
? typeof Buffer != "undefined" && Buffer.isBuffer(result) | ||
? result.toString(encoding as BufferEncoding) | ||
: new TextDecoder(encoding).decode(result) | ||
: result; | ||
} | ||
|
||
export = nor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
import { _internal } from "."; | ||
|
||
/** Performs a bitwise NOT operation on each byte of the given data. */ | ||
function not(data: string | ArrayBuffer | NodeJS.ArrayBufferView, encoding: string): string; | ||
function not( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
encoding: string | ||
): string; | ||
function not(data: string | ArrayBuffer | NodeJS.ArrayBufferView): Uint8Array; | ||
function not(data: string | ArrayBuffer | NodeJS.ArrayBufferView, encoding?: string): string | Uint8Array { | ||
const result = _internal.toBuffer(data).map(x => x ^ 255 & 255); | ||
return encoding ? ((typeof Buffer != "undefined" && Buffer.isBuffer(result)) ? | ||
result.toString(encoding as BufferEncoding) : new TextDecoder(encoding).decode(result)) : result; | ||
function not( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
encoding?: string | ||
): string | Uint8Array { | ||
const result = _internal.toBuffer(data).map(x => x ^ (255 & 255)); | ||
return encoding | ||
? typeof Buffer != "undefined" && Buffer.isBuffer(result) | ||
? result.toString(encoding as BufferEncoding) | ||
: new TextDecoder(encoding).decode(result) | ||
: result; | ||
} | ||
|
||
export = not; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,27 @@ | ||
import { _internal } from "."; | ||
|
||
/** Performs a bitwise OR operation on each byte of the given data using the given key. */ | ||
function or(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number, encoding: string): string; | ||
function or(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number): Uint8Array; | ||
function or(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number, encoding?: string): string | Uint8Array { | ||
function or( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number, | ||
encoding: string | ||
): string; | ||
function or( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number | ||
): Uint8Array; | ||
function or( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number, | ||
encoding?: string | ||
): string | Uint8Array { | ||
const k = !isNaN(key) ? Number(key) : 0; | ||
const result = _internal.toBuffer(data).map(x => x | k & 255); | ||
return encoding ? ((typeof Buffer != "undefined" && Buffer.isBuffer(result)) ? | ||
result.toString(encoding as BufferEncoding) : new TextDecoder(encoding).decode(result)) : result; | ||
const result = _internal.toBuffer(data).map(x => x | (k & 255)); | ||
return encoding | ||
? typeof Buffer != "undefined" && Buffer.isBuffer(result) | ||
? result.toString(encoding as BufferEncoding) | ||
: new TextDecoder(encoding).decode(result) | ||
: result; | ||
} | ||
|
||
export = or; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,27 @@ | ||
import { _internal } from "."; | ||
|
||
/** Subtracts the given key from each byte of the given data. */ | ||
function subtract(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number, encoding: string): string; | ||
function subtract(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number): Uint8Array; | ||
function subtract(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number, encoding?: string): string | Uint8Array { | ||
function subtract( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number, | ||
encoding: string | ||
): string; | ||
function subtract( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number | ||
): Uint8Array; | ||
function subtract( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number, | ||
encoding?: string | ||
): string | Uint8Array { | ||
const k = !isNaN(key) ? Number(key) : 0; | ||
const result = _internal.toBuffer(data).map(x => x - k & 255); | ||
return encoding ? ((typeof Buffer != "undefined" && Buffer.isBuffer(result)) ? | ||
result.toString(encoding as BufferEncoding) : new TextDecoder(encoding).decode(result)) : result; | ||
const result = _internal.toBuffer(data).map(x => (x - k) & 255); | ||
return encoding | ||
? typeof Buffer != "undefined" && Buffer.isBuffer(result) | ||
? result.toString(encoding as BufferEncoding) | ||
: new TextDecoder(encoding).decode(result) | ||
: result; | ||
} | ||
|
||
export = subtract; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,27 @@ | ||
import { _internal } from "."; | ||
|
||
/** Performs a bitwise XNOR operation on each byte of the given data using the given key. */ | ||
function xnor(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number, encoding: string): string; | ||
function xnor(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number): Uint8Array; | ||
function xnor(data: string | ArrayBuffer | NodeJS.ArrayBufferView, key: number, encoding?: string): string | Uint8Array { | ||
function xnor( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number, | ||
encoding: string | ||
): string; | ||
function xnor( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number | ||
): Uint8Array; | ||
function xnor( | ||
data: string | ArrayBuffer | NodeJS.ArrayBufferView, | ||
key: number, | ||
encoding?: string | ||
): string | Uint8Array { | ||
const k = !isNaN(key) ? Number(key) : 0; | ||
const result = _internal.toBuffer(data).map(x => (x ^ k & 255) ^ 255); | ||
return encoding ? ((typeof Buffer != "undefined" && Buffer.isBuffer(result)) ? | ||
result.toString(encoding as BufferEncoding) : new TextDecoder(encoding).decode(result)) : result; | ||
const result = _internal.toBuffer(data).map(x => x ^ (k & 255) ^ 255); | ||
return encoding | ||
? typeof Buffer != "undefined" && Buffer.isBuffer(result) | ||
? result.toString(encoding as BufferEncoding) | ||
: new TextDecoder(encoding).decode(result) | ||
: result; | ||
} | ||
|
||
export = xnor; |
Oops, something went wrong.