LS47 implemented, needs linting

This commit is contained in:
n1073645 2020-01-27 16:07:54 +00:00
parent ace8121d0e
commit 0259ed8314
3 changed files with 269 additions and 0 deletions

View file

@ -0,0 +1,58 @@
/**
* @author n1073645 [n1073645@gmail.com]
* @copyright Crown Copyright 2020
* @license Apache-2.0
*/
import Operation from "../Operation.mjs";
import * as LS47 from "../lib/LS47.mjs"
/**
* LS47 Decrypt operation
*/
class LS47Decrypt extends Operation {
/**
* LS47Decrypt constructor
*/
constructor() {
super();
this.name = "LS47 Decrypt";
this.module = "Crypto";
this.description = "";
this.infoURL = "";
this.inputType = "string";
this.outputType = "string";
this.args = [
{
name: "Password",
type: "string",
value: ""
},
{
name: "Padding",
type: "number",
value: 10
}
];
}
/**
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
this.padding_size = parseInt(args[1], 10);
LS47.init_tiles();
let key = LS47.derive_key(args[0]);
return LS47.decrypt_pad(key, input, this.padding_size);
}
}
export default LS47Decrypt;

View file

@ -0,0 +1,63 @@
/**
* @author n1073645 [n1073645@gmail.com]
* @copyright Crown Copyright 2020
* @license Apache-2.0
*/
import Operation from "../Operation.mjs";
import * as LS47 from "../lib/LS47.mjs"
/**
* LS47 Encrypt operation
*/
class LS47Encrypt extends Operation {
/**
* LS47Encrypt constructor
*/
constructor() {
super();
this.name = "LS47 Encrypt";
this.module = "Crypto";
this.description = "";
this.infoURL = "";
this.inputType = "string";
this.outputType = "string";
this.args = [
{
name: "Password",
type: "string",
value: ""
},
{
name: "Padding",
type: "number",
value: 10
},
{
name: "Signature",
type: "string",
value: ""
}
];
}
/**
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
this.padding_size = parseInt(args[1], 10);
LS47.init_tiles();
let key = LS47.derive_key(args[0]);
return LS47.encrypt_pad(key, input, args[2], this.padding_size);
}
}
export default LS47Encrypt;