mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 06:55:08 -04:00
feat: support UUID v1, v3, v4, v5, v6, v7
- Add v6 and v7 as valid options - Add unit tests for generating and analyzing all supported versions
This commit is contained in:
parent
e0bdde89c4
commit
457d28fc55
2 changed files with 12 additions and 12 deletions
|
@ -20,7 +20,7 @@ class GenerateUUID extends Operation {
|
||||||
|
|
||||||
this.name = "Generate UUID";
|
this.name = "Generate UUID";
|
||||||
this.module = "Crypto";
|
this.module = "Crypto";
|
||||||
this.description = "Generates an RFC 4122 compliant Universally Unique Identifier (UUID), also known as a Globally Unique Identifier (GUID).<br><br>A version 4 UUID relies on random numbers, in this case generated using <code>uuid</code> package";
|
this.description = "Generates an RFC 9562 (formerly RFC 4122) compliant Universally Unique Identifier (UUID), also known as a Globally Unique Identifier (GUID).<br><br>A version 4 UUID relies on random numbers, in this case generated using <code>uuid</code> package";
|
||||||
this.infoURL = "https://wikipedia.org/wiki/Universally_unique_identifier";
|
this.infoURL = "https://wikipedia.org/wiki/Universally_unique_identifier";
|
||||||
this.inputType = "string";
|
this.inputType = "string";
|
||||||
this.outputType = "string";
|
this.outputType = "string";
|
||||||
|
@ -29,7 +29,7 @@ class GenerateUUID extends Operation {
|
||||||
name: "UUID Version",
|
name: "UUID Version",
|
||||||
type: "option",
|
type: "option",
|
||||||
value: [
|
value: [
|
||||||
"v1", "v3", "v4", "v5"
|
"v1", "v3", "v4", "v5", "v6", "v7",
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -580,18 +580,18 @@ Password: 282760`;
|
||||||
assert.strictEqual(result.toString().substr(0, 37), "-----BEGIN PGP PRIVATE KEY BLOCK-----");
|
assert.strictEqual(result.toString().substr(0, 37), "-----BEGIN PGP PRIVATE KEY BLOCK-----");
|
||||||
}),
|
}),
|
||||||
|
|
||||||
it("Generate UUID v1", () => {
|
...[1, 3, 4, 5, 6, 7].map(version => it(`Generate UUID v${version}`, () => {
|
||||||
const result = chef.generateUUID("", { version: "v1" }).toString();
|
const result = chef.generateUUID("", { "UUID version": `v${version}` }).toString();
|
||||||
assert.ok(result);
|
assert.ok(result);
|
||||||
assert.equal(result.length, 36);
|
assert.strictEqual(result.length, 36);
|
||||||
}),
|
})),
|
||||||
|
|
||||||
it("Analyse UUID v1", () => {
|
...[1, 3, 4, 5, 6, 7].map(version => it(`Analyze UUID v${version}`, () => {
|
||||||
const uuidv1 = chef.generateUUID("", { version: "v1" }).toString();
|
const uuid = chef.generateUUID("", { "UUID version": `v${version}` }).toString();
|
||||||
const uuidAnalysis = chef.analyseUUID(uuidv1).toString();
|
const result = chef.analyseUUID(uuid).toString();
|
||||||
|
const expected = `UUID version: ${version}`;
|
||||||
assert.equal(uuidAnalysis, "UUID version: 1");
|
assert.strictEqual(result, expected);
|
||||||
}),
|
})),
|
||||||
|
|
||||||
it("Gzip, Gunzip", () => {
|
it("Gzip, Gunzip", () => {
|
||||||
assert.strictEqual(chef.gunzip(chef.gzip("Down To The Wire")).toString(), "Down To The Wire");
|
assert.strictEqual(chef.gunzip(chef.gzip("Down To The Wire")).toString(), "Down To The Wire");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue