Skip to content

Commit e6c7899

Browse files
committed
Merge branch 'EPOCH' of https://github.com/n1073645/CyberChef into n1073645-EPOCH
2 parents a74a141 + 7526f4d commit e6c7899

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

src/core/config/Categories.json

+1
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@
267267
"Windows Filetime to UNIX Timestamp",
268268
"UNIX Timestamp to Windows Filetime",
269269
"Extract dates",
270+
"Generate Current Epoch",
270271
"Sleep"
271272
]
272273
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* @author n1073645 [[email protected]]
3+
* @copyright Crown Copyright 2020
4+
* @license Apache-2.0
5+
*/
6+
7+
import Operation from "../Operation.mjs";
8+
9+
/**
10+
* GenerateCurrentEpoch operation
11+
*/
12+
class GenerateCurrentEpoch extends Operation {
13+
14+
/**
15+
* GenerateCurrentEpoch constructor
16+
*/
17+
constructor() {
18+
super();
19+
20+
this.name = "Generate Current Epoch";
21+
this.module = "Default";
22+
this.description = "Generates the current time(in seconds/milliseconds) since the UNIX epoch.";
23+
this.infoURL = "https://wikipedia.org/wiki/Unix_time";
24+
this.inputType = "string";
25+
this.outputType = "string";
26+
this.args = [
27+
{
28+
name: "Granularity",
29+
type: "option",
30+
value: ["Milliseconds", "Seconds"]
31+
}
32+
];
33+
}
34+
35+
/**
36+
* @param {string} input
37+
* @param {Object[]} args
38+
* @returns {string}
39+
*/
40+
run(input, args) {
41+
if (args[0] === "Milliseconds")
42+
return (new Date()).getTime().toString();
43+
else
44+
return Math.round((new Date()).getTime() / 1000).toString();
45+
}
46+
47+
}
48+
49+
export default GenerateCurrentEpoch;

0 commit comments

Comments
 (0)