mirror of
https://github.com/gchq/CyberChef.git
synced 2026-02-10 17:55:56 -08:00
feat(encodings): enable Base91 detection in Magic and add tests
- Add detection checks for "From Base91" (regex heuristic), consistent with existing Base64/Base85 patterns - Regenerate OperationConfig.json via script to keep metadata in sync - Add unit tests for Base91 encode/decode and a Magic chain test for Base91 Authored-by: Izai Alejandro Zalles Merino <zallesrene@gmail.com>
This commit is contained in:
parent
d6ec7639b0
commit
2984d80b38
4 changed files with 59 additions and 0 deletions
|
|
@ -23,6 +23,17 @@ class FromBase91 extends Operation {
|
|||
this.infoURL = "https://en.wikipedia.org/wiki/Binary-to-text_encoding#Encoding_standards";
|
||||
this.inputType = "string";
|
||||
this.outputType = "ArrayBuffer";
|
||||
this.checks = [
|
||||
{
|
||||
pattern:
|
||||
"^" +
|
||||
"[\\s0-9A-Za-z!#$%&()*+,./:;<=>?@\\\[\\\]\\^_`{|}~\"]*" +
|
||||
"[0-9A-Za-z!#$%&()*+,./:;<=>?@\\\[\\\]\\^_`{|}~\"]{15}" +
|
||||
"[\\s0-9A-Za-z!#$%&()*+,./:;<=>?@\\\[\\\]\\^_`{|}~\"]*" +
|
||||
"$",
|
||||
args: []
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import "./tests/Base58.mjs";
|
|||
import "./tests/Base62.mjs";
|
||||
import "./tests/Base64.mjs";
|
||||
import "./tests/Base85.mjs";
|
||||
import "./tests/Base91.mjs";
|
||||
import "./tests/Base92.mjs";
|
||||
import "./tests/BCD.mjs";
|
||||
import "./tests/BitwiseOp.mjs";
|
||||
|
|
|
|||
35
tests/operations/tests/Base91.mjs
Normal file
35
tests/operations/tests/Base91.mjs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* Base91 tests
|
||||
*
|
||||
* @author ialejandrozalles
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "To Base91",
|
||||
input: "hello",
|
||||
expectedOutput: "TPwJh>A",
|
||||
recipeConfig: [
|
||||
{ op: "To Base91", args: [] }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "From Base91",
|
||||
input: "TPwJh>A",
|
||||
expectedOutput: "hello",
|
||||
recipeConfig: [
|
||||
{ op: "From Base91", args: [] }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "To/From Base91 Roundtrip",
|
||||
input: "The quick brown fox jumps over the lazy dog",
|
||||
expectedOutput: "The quick brown fox jumps over the lazy dog",
|
||||
recipeConfig: [
|
||||
{ op: "To Base91", args: [] },
|
||||
{ op: "From Base91", args: [] }
|
||||
]
|
||||
}
|
||||
]);
|
||||
|
|
@ -153,4 +153,16 @@ TestRegister.addTests([
|
|||
}
|
||||
]
|
||||
}
|
||||
,
|
||||
{
|
||||
name: "Magic Chain: Base91",
|
||||
input: "xD7ghoHB4!#/Tm_ogr$J9[JTrUJ*|jgSr!=EWoFB",
|
||||
expectedMatch: /From_Base91\(\)/,
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Magic",
|
||||
args: [3, false, false]
|
||||
}
|
||||
],
|
||||
}
|
||||
]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue