From ae5648ede1235ef78a0d451d4fb40f8f1500eff6 Mon Sep 17 00:00:00 2001 From: victorlpgazolli Date: Tue, 21 Mar 2023 18:38:39 -0300 Subject: [PATCH] add analyse uuid version --- src/core/operations/AnalyseUUID.mjs | 47 +++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/core/operations/AnalyseUUID.mjs diff --git a/src/core/operations/AnalyseUUID.mjs b/src/core/operations/AnalyseUUID.mjs new file mode 100644 index 00000000..cde3c3cb --- /dev/null +++ b/src/core/operations/AnalyseUUID.mjs @@ -0,0 +1,47 @@ +/** + * @author n1474335 [n1474335@gmail.com] + * @copyright Crown Copyright 2023 + * @license Apache-2.0 + */ + +import Operation from "../Operation.mjs"; +import * as uuid from "uuid"; +import OperationError from "../errors/OperationError.mjs"; + +/** + * Analyse hash operation + */ +class AnalyseHash extends Operation { + + /** + * AnalyseHash constructor + */ + constructor() { + super(); + + this.name = "Analyse UUID"; + this.module = "Crypto"; + this.description = "Tries to determine information about a given UUID and suggests which version may have been used to generate it"; + this.infoURL = "https://wikipedia.org/wiki/Universally_unique_identifier"; + this.inputType = "string"; + this.outputType = "string"; + this.args = []; + } + + /** + * @param {string} input + * @param {Object[]} args + * @returns {string} + */ + run(input, args) { + try { + const uuidVersion = uuid.version(input); + return "UUID version: " + uuidVersion; + } catch (error) { + throw new OperationError("Invalid UUID"); + } + } + +} + +export default AnalyseHash;