mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 23:36:16 -04:00
Merge branch 'EPOCH' of https://github.com/n1073645/CyberChef into n1073645-EPOCH
This commit is contained in:
commit
e6c7899569
2 changed files with 50 additions and 0 deletions
|
@ -267,6 +267,7 @@
|
||||||
"Windows Filetime to UNIX Timestamp",
|
"Windows Filetime to UNIX Timestamp",
|
||||||
"UNIX Timestamp to Windows Filetime",
|
"UNIX Timestamp to Windows Filetime",
|
||||||
"Extract dates",
|
"Extract dates",
|
||||||
|
"Generate Current Epoch",
|
||||||
"Sleep"
|
"Sleep"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
49
src/core/operations/GenerateCurrentEpoch.mjs
Normal file
49
src/core/operations/GenerateCurrentEpoch.mjs
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
/**
|
||||||
|
* @author n1073645 [n1073645@gmail.com]
|
||||||
|
* @copyright Crown Copyright 2020
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GenerateCurrentEpoch operation
|
||||||
|
*/
|
||||||
|
class GenerateCurrentEpoch extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GenerateCurrentEpoch constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "Generate Current Epoch";
|
||||||
|
this.module = "Default";
|
||||||
|
this.description = "Generates the current time(in seconds/milliseconds) since the UNIX epoch.";
|
||||||
|
this.infoURL = "https://wikipedia.org/wiki/Unix_time";
|
||||||
|
this.inputType = "string";
|
||||||
|
this.outputType = "string";
|
||||||
|
this.args = [
|
||||||
|
{
|
||||||
|
name: "Granularity",
|
||||||
|
type: "option",
|
||||||
|
value: ["Milliseconds", "Seconds"]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
if (args[0] === "Milliseconds")
|
||||||
|
return (new Date()).getTime().toString();
|
||||||
|
else
|
||||||
|
return Math.round((new Date()).getTime() / 1000).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default GenerateCurrentEpoch;
|
Loading…
Add table
Add a link
Reference in a new issue