mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-22 07:46:16 -04:00
Merge branch 'master' of https://github.com/bwhitn/CyberChef into bwhitn-master
This commit is contained in:
commit
15decd9cd9
5 changed files with 117 additions and 0 deletions
|
@ -1,3 +1,5 @@
|
|||
import {BigInteger} from "jsbn";
|
||||
|
||||
/**
|
||||
* Date and time operations.
|
||||
*
|
||||
|
@ -78,6 +80,58 @@ const DateTime = {
|
|||
},
|
||||
|
||||
|
||||
/**
|
||||
* Converts a Windows FILETIME to Unix Epoch time.
|
||||
*
|
||||
* @author bwhitn [brian.m.whitney@outlook.com]
|
||||
* @param {string} input
|
||||
* @param {Object[]} args (not used)
|
||||
* @returns {string}
|
||||
*/
|
||||
runFromFiletimeToUnix: function(input, args) {
|
||||
let units = args[0];
|
||||
input = new BigInteger(input).subtract(new BigInteger("116444736000000000"));
|
||||
if (units === "Seconds (s)"){
|
||||
input = input.divide(new BigInteger("10000000"));
|
||||
} else if (units === "Milliseconds (ms)") {
|
||||
input = input.divide(new BigInteger("10000"));
|
||||
} else if (units === "Microseconds (μs)") {
|
||||
input = input.divide(new BigInteger("10"));
|
||||
} else if (units === "Nanoseconds (ns)") {
|
||||
input = input.multiply(new BigInteger("100"));
|
||||
} else {
|
||||
throw "Unrecognised unit";
|
||||
}
|
||||
return input.toString();
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Converts a Unix Epoch time to Windows FILETIME.
|
||||
*
|
||||
* @author bwhitn [brian.m.whitney@outlook.com]
|
||||
* @param {string} input
|
||||
* @param {Object[]} args (not used)
|
||||
* @returns {string}
|
||||
*/
|
||||
runToFiletimeFromUnix: function(input, args) {
|
||||
let units = args[0];
|
||||
input = new BigInteger(input);
|
||||
if (units === "Seconds (s)"){
|
||||
input = input.multiply(new BigInteger("10000000"));
|
||||
} else if (units === "Milliseconds (ms)") {
|
||||
input = input.multiply(new BigInteger("10000"));
|
||||
} else if (units === "Microseconds (μs)") {
|
||||
input = input.multiply(new BigInteger("10"));
|
||||
} else if (units === "Nanoseconds (ns)") {
|
||||
input = input.divide(new BigInteger("100"));
|
||||
} else {
|
||||
throw "Unrecognised unit";
|
||||
}
|
||||
return input.add(new BigInteger("116444736000000000")).toString();
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue