2
0
mirror of https://github.com/gchq/CyberChef synced 2025-12-15 15:53:30 +00:00

add in the word args. empty dish is now ArrayBuffer

d98762625
2019-04-08 18:07:58 +01:00
parent a6fa501c9e
commit 2be3999715

@@ -152,8 +152,8 @@ chef.convertDistance(122, {
// Less error-prone // Less error-prone
chef.convertDistance(122, { chef.convertDistance(122, {
inputUnits: chef.convertDistance..inputUnits.options[5], inputUnits: chef.convertDistance.args.inputUnits.options[5],
outputUnits: chef.convertDistance..outputUnits.options[17] outputUnits: chef.convertDistance.args.outputUnits.options[17]
}) })
// => 30500 // => 30500
@@ -167,11 +167,11 @@ chef.convertDistance(122, {
#### Operation input #### Operation input
Operations accept a wide range of input types, such as strings, numbers and byteArrays. For most cases, you can throw any input type at an operation and it will deal with it. Operations accept a wide range of input types, such as strings, numbers, byteArrays and ArrayBuffers. For most cases, you can throw any input type at an operation and it will deal with it.
If the given input to an operation is not the operation's input type, it will attempt to convert the input before operating on it. For example, `toBase32`'s input type is `byteArray`, so if you input a string, it converts that string into a byte array before running the operation. If the given input to an operation is not the operation's input type, it will attempt to convert the input before operating on it. For example, `toBase32`'s input type is `byteArray`, so if you input a string, it converts that string into a byte array before running the operation.
Files from `fs` can be read into appropriate functions in chef. They are converted into `byteArray`s. Files from `fs` can be read into appropriate functions in chef. They are converted into `ArrayBuffer`s.
JavaScript objects are accepted as input to operations that expect JSON, for example, `JSONBeautify`. JavaScript objects are accepted as input to operations that expect JSON, for example, `JSONBeautify`.
@@ -211,7 +211,7 @@ chef.toDecimal("Hello", {
// Equivalent and less error-prone: // Equivalent and less error-prone:
chef.toDecimal("Hello", { chef.toDecimal("Hello", {
delimiter: chef.toDecimal..delimiter.options[3], delimiter: chef.toDecimal.args.delimiter.options[3],
}); });
// => 72:101:108:108:111 // => 72:101:108:108:111
``` ```
@@ -226,12 +226,12 @@ chef.ADD("abc", {
}); });
``` ```
Example: `ADD` with explicit encoding. Note the property `toggleValues` rather than `options` in the `` object. Example: `ADD` with explicit encoding. Note the property `toggleValues` rather than `options` in the `args` object.
```javascript ```javascript
chef.ADD("abc", { chef.ADD("abc", {
key: { key: {
string: "123", string: "123",
option: chef.ADD..key.toggleValues[4], option: chef.ADD.args.key.toggleValues[4],
}, },
}); });
``` ```
@@ -252,7 +252,7 @@ console.log(result); // => 32
assert.equal(result + 3, 35); // OK assert.equal(result + 3, 35); // OK
// String coercion // String coercion
assert.equal(result.toString(), "32"); // => true; assert.equal(result.toString(), "32"); // OK
``` ```
The `value` property of an operation result will give the raw result. For example: The `value` property of an operation result will give the raw result. For example:
@@ -318,7 +318,7 @@ If there is more than one match for the given search term, `help` will return mu
#### `bake` #### `bake`
`bake` is useful for building "recipes" - chains of operations to apply to some input, in order. `bake` accepts operations in multiple ways. It always returns a `Dish` object. `bake` is useful for building "recipes" - chains of operations to apply to some input, in order. `bake` accepts operations in multiple ways. It always returns a `Dish` object.
One operation, no One operation, no arguments
```javascript ```javascript
chef.bake("I'll have the cod.", chef.toBase64); chef.bake("I'll have the cod.", chef.toBase64);
// => SSdsbCBoYXZlIHRoZSBjb2Qu // => SSdsbCBoYXZlIHRoZSBjb2Qu
@@ -328,35 +328,35 @@ One operation by name
chef.bake("I'll have the cod.", "to base 64"); chef.bake("I'll have the cod.", "to base 64");
// => SSdsbCBoYXZlIHRoZSBjb2Qu // => SSdsbCBoYXZlIHRoZSBjb2Qu
``` ```
Multiple operations, by name or by function (default ) Multiple operations, by name or by function (default arguments)
```javascript ```javascript
chef.bake("I'll have the cod", [chef.toBase64, "sha1"]); chef.bake("I'll have the cod", [chef.toBase64, "sha1"]);
// => f20135964d60f5fb66f971f5ee33d8395d1f90bf // => f20135964d60f5fb66f971f5ee33d8395d1f90bf
``` ```
One operation, with custom One operation, with custom arguments
```javascript ```javascript
chef.bake("I'll have the salmon.", { chef.bake("I'll have the salmon.", {
op: chef.toBase64, op: chef.toBase64,
: { args: {
alphabet: "A-Z", alphabet: "A-Z",
}, },
}); });
// => SSCBYXZIHRZSBYW // => SSCBYXZIHRZSBYW
``` ```
Multiple operations with custom Multiple operations with custom arguments
```javascript ```javascript
chef.bake("I'll have the salmon.", [ chef.bake("I'll have the salmon.", [
{ {
op: chef.toBase64, op: chef.toBase64,
: { args: {
alphabet: "A-Z" alphabet: "A-Z"
} }
}, },
{ {
op: chef.sort, op: chef.sort,
: { args: {
delimiter: "Nothing (separate chars)", delimiter: "Nothing (separate chars)",
reverse: true, reverse: true,
} }
@@ -372,9 +372,9 @@ chef.bake("I'll have the salmon.", [
// taken from CyberChef web export // taken from CyberChef web export
const recipe = [ const recipe = [
{ "op": "To Base64", { "op": "To Base64",
"": ["A-Z"] }, "args": ["A-Z"] },
{ "op": "Sort", { "op": "Sort",
"": ["Nothing (separate chars)", true, "Alphabetical (case sensitive)"] } "args": ["Nothing (separate chars)", true, "Alphabetical (case sensitive)"] }
]; ];
chef.bake("I'll have the salmon.", recipe); chef.bake("I'll have the salmon.", recipe);
@@ -404,8 +404,8 @@ Dish will coerce to a String or an Number where appropriate.
Empty Dish contructor Empty Dish contructor
```javascript ```javascript
const dish = new chef.Dish(); const dish = new chef.Dish();
dish.value; // => [] dish.value; // => ArrayBuffer {byteLength: 0}
dish.type; // => 0 (byteArray) dish.type; // => 4
``` ```
Dish with type implied from input Dish with type implied from input