mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-24 16:56:15 -04:00
Merge pull request #1991 from peterc-s/master
Add Base32 Hex Extended Alphabet and Base32 Tests.
This commit is contained in:
commit
74d631c71e
5 changed files with 214 additions and 4 deletions
23
src/core/lib/Base32.mjs
Normal file
23
src/core/lib/Base32.mjs
Normal file
|
@ -0,0 +1,23 @@
|
|||
// import Utils from "../Utils.mjs";
|
||||
|
||||
/**
|
||||
* Base32 resources.
|
||||
*
|
||||
* @author Peter C-S [petercs@purelymail.com]
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base32 alphabets.
|
||||
*/
|
||||
export const ALPHABET_OPTIONS = [
|
||||
{
|
||||
name: "Standard", // https://www.rfc-editor.org/rfc/rfc4648#section-6
|
||||
value: "A-Z2-7=",
|
||||
},
|
||||
{
|
||||
name: "Hex Extended", // https://www.rfc-editor.org/rfc/rfc4648#section-7
|
||||
value: "0-9A-V=",
|
||||
},
|
||||
];
|
||||
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
import Operation from "../Operation.mjs";
|
||||
import Utils from "../Utils.mjs";
|
||||
import {ALPHABET_OPTIONS} from "../lib/Base32.mjs";
|
||||
|
||||
|
||||
/**
|
||||
* From Base32 operation
|
||||
|
@ -27,8 +29,8 @@ class FromBase32 extends Operation {
|
|||
this.args = [
|
||||
{
|
||||
name: "Alphabet",
|
||||
type: "binaryString",
|
||||
value: "A-Z2-7="
|
||||
type: "editableOption",
|
||||
value: ALPHABET_OPTIONS
|
||||
},
|
||||
{
|
||||
name: "Remove non-alphabet chars",
|
||||
|
@ -41,6 +43,11 @@ class FromBase32 extends Operation {
|
|||
pattern: "^(?:[A-Z2-7]{8})+(?:[A-Z2-7]{2}={6}|[A-Z2-7]{4}={4}|[A-Z2-7]{5}={3}|[A-Z2-7]{7}={1})?$",
|
||||
flags: "",
|
||||
args: ["A-Z2-7=", false]
|
||||
},
|
||||
{
|
||||
pattern: "^(?:[0-9A-V]{8})+(?:[0-9A-V]{2}={6}|[0-9A-V]{4}={4}|[0-9A-V]{5}={3}|[0-9A-V]{7}={1})?$",
|
||||
flags: "",
|
||||
args: ["0-9A-V=", false]
|
||||
}
|
||||
];
|
||||
}
|
||||
|
@ -96,3 +103,4 @@ class FromBase32 extends Operation {
|
|||
}
|
||||
|
||||
export default FromBase32;
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
import Operation from "../Operation.mjs";
|
||||
import Utils from "../Utils.mjs";
|
||||
import {ALPHABET_OPTIONS} from "../lib/Base32.mjs";
|
||||
|
||||
/**
|
||||
* To Base32 operation
|
||||
|
@ -27,8 +28,8 @@ class ToBase32 extends Operation {
|
|||
this.args = [
|
||||
{
|
||||
name: "Alphabet",
|
||||
type: "binaryString",
|
||||
value: "A-Z2-7="
|
||||
type: "editableOption",
|
||||
value: ALPHABET_OPTIONS
|
||||
}
|
||||
];
|
||||
}
|
||||
|
@ -83,3 +84,4 @@ class ToBase32 extends Operation {
|
|||
}
|
||||
|
||||
export default ToBase32;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue