Fix linter

This commit is contained in:
Karsten Silkenbäumer 2019-02-26 22:46:56 +01:00
parent dcee118f4a
commit 9ac188d398
5 changed files with 320 additions and 324 deletions

View File

@ -4,8 +4,7 @@
* @license Apache-2.0 * @license Apache-2.0
*/ */
import Operation from '../Operation'; import Operation from "../Operation";
import OperationError from "../errors/OperationError";
/** /**
* BaconCipherDecode operation * BaconCipherDecode operation
@ -14,31 +13,30 @@ class BaconCipherDecode extends Operation {
/** /**
* BaconCipherDecode constructor * BaconCipherDecode constructor
*/ */
constructor() { constructor() {
super(); super();
this.name = 'Bacon Cipher Decode'; this.name = "Bacon Cipher Decode";
this.module = 'Default'; this.module = "Default";
this.description = 'Bacon\'s cipher or the Baconian cipher is a method of steganography(a method of hiding a secret message as opposed to just a cipher) devised by Francis Bacon in 1605.[1][2][3] A message is concealed in the presentation of text, rather than its content.'; this.description = "Bacon's cipher or the Baconian cipher is a method of steganography(a method of hiding a secret message as opposed to just a cipher) devised by Francis Bacon in 1605.[1][2][3] A message is concealed in the presentation of text, rather than its content.";
this.infoURL = 'https://en.wikipedia.org/wiki/Bacon%27s_cipher'; this.infoURL = "https://en.wikipedia.org/wiki/Bacon%27s_cipher";
this.inputType = 'string'; this.inputType = "string";
this.outputType = 'string'; this.outputType = "string";
this.args = [ this.args = [
{ {
'name': 'Alphabet', "name": "Alphabet",
'type': 'option', "type": "option",
'value': ['ABCDEFGHIKLMNOPQRSTUWXYZ', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'] "value": ["ABCDEFGHIKLMNOPQRSTUWXYZ", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
}, },
{ {
'name': 'Translation', "name": "Translation",
'type': 'option', "type": "option",
'value': ['0/1', 'A/B', 'Case', 'A-M/N-Z'] "value": ["0/1", "A/B", "Case", "A-M/N-Z"]
}, },
{ {
'name': 'Invert Translation', "name": "Invert Translation",
'type': 'boolean', "type": "boolean",
'value': false "value": false
} }
]; ];
} }
@ -53,27 +51,26 @@ class BaconCipherDecode extends Operation {
const regexAM = /[A-M]/; const regexAM = /[A-M]/;
const regexNZ = /[N-Z]/; const regexNZ = /[N-Z]/;
// split text into groups of 5 characters // split text into groups of 5 characters
var groups = []; const groups = [];
var group = ""; let group = "";
for (let index = 0; index < input.length; index++) { for (let index = 0; index < input.length; index++) {
const char = input[index]; const char = input[index];
console.log(char);
if (char.toLowerCase() != char.toUpperCase()) { if (char.toLowerCase() !== char.toUpperCase()) {
switch (translation) { switch (translation) {
case "0/1": case "0/1":
group = group + char; group = group + char;
break; break;
case "A/B": case "A/B":
if (char == "A") { if (char === "A") {
group = group + "1"; group = group + "1";
} else if (char == "B") { } else if (char === "B") {
group = group + "0"; group = group + "0";
} }
break; break;
case "Case": case "Case":
if (char == char.toUpperCase()) { if (char === char.toUpperCase()) {
group = group + "1"; group = group + "1";
} else { } else {
group = group + "0"; group = group + "0";
@ -82,16 +79,15 @@ class BaconCipherDecode extends Operation {
case "A-M/N-Z": case "A-M/N-Z":
if (char.match(regexAM)) { if (char.match(regexAM)) {
group = group + "1"; group = group + "1";
} } else if (char.match(regexNZ)) {
else if (char.match(regexNZ)) { group = group + "0";
group = group + "0"
} }
break; break;
default: default:
break; break;
} }
if (group.length == 5) { if (group.length === 5) {
groups.push(group); groups.push(group);
group = ""; group = "";
} }
@ -107,25 +103,25 @@ class BaconCipherDecode extends Operation {
let output = ""; let output = "";
const byteLen = 5; const byteLen = 5;
for (let index = 0; index < groups.length; index++) { for (let index = 0; index < groups.length; index++) {
var group = groups[index]; let group = groups[index];
if (invert) { if (invert) {
group = group.replace(/[01]/g, function (m) { group = group.replace(/[01]/g, function (m) {
return { return {
'0': '1', "0": "1",
'1': '0' "1": "0"
}[m]; }[m];
}); });
} }
// calculate binary value // calculate binary value
var number; let number;
for (let i = 0; i < group.length; i += byteLen) { for (let i = 0; i < group.length; i += byteLen) {
number = parseInt(group.substr(i, byteLen), 2); number = parseInt(group.substr(i, byteLen), 2);
} }
var char; let char;
if (number < alphabet.length) { if (number < alphabet.length) {
char = alphabet[number]; char = alphabet[number];
} else { } else {
char = "?" char = "?";
} }
output += char; output += char;
} }

View File

@ -4,7 +4,7 @@
* @license Apache-2.0 * @license Apache-2.0
*/ */
import Operation from '../Operation'; import Operation from "../Operation";
/** /**
* Brainfuck operation * Brainfuck operation
@ -13,21 +13,20 @@ class Brainfuck extends Operation {
/** /**
* Brainfuck constructor * Brainfuck constructor
*/ */
constructor () { constructor () {
super(); super();
this.name = 'Brainfuck'; this.name = "Brainfuck";
this.module = 'Default'; this.module = "Default";
this.description = 'Brainfuck is the most famous esoteric programming language, and has inspired the creation of a host of other languages. Due to the fact that the last half of its name is often considered one of the most offensive words in the English language, it is sometimes referred to as brainf***, brainf*ck, brainfsck, b****fuck, brainf**k, branflakes, or BF. This can make it a bit difficult to search for information regarding brainfuck on the web, as the proper name might not be used at all in some articles.'; this.description = "Brainfuck is the most famous esoteric programming language, and has inspired the creation of a host of other languages. Due to the fact that the last half of its name is often considered one of the most offensive words in the English language, it is sometimes referred to as brainf***, brainf*ck, brainfsck, b****fuck, brainf**k, branflakes, or BF. This can make it a bit difficult to search for information regarding brainfuck on the web, as the proper name might not be used at all in some articles.";
this.infoURL = 'http://esolangs.org/wiki/Brainfuck'; this.infoURL = "http://esolangs.org/wiki/Brainfuck";
this.inputType = 'string'; this.inputType = "string";
this.outputType = 'string'; this.outputType = "string";
this.args = [ this.args = [
{ {
'name': 'User Input', "name": "User Input",
'type': 'text', "type": "text",
'value': '' "value": ""
} }
]; ];
} }
@ -39,8 +38,8 @@ class Brainfuck extends Operation {
*/ */
run (input, args) { run (input, args) {
const [userInput] = args; const [userInput] = args;
var brainfuck = require('brainfuck-javascript'); const brainfuck = require("brainfuck-javascript");
let output = brainfuck.text(input, userInput); const output = brainfuck.text(input, userInput);
return output; return output;
} }
} }

View File

@ -4,7 +4,7 @@
* @license Apache-2.0 * @license Apache-2.0
*/ */
import Operation from '../Operation'; import Operation from "../Operation";
/** /**
* FernetDecrypt operation * FernetDecrypt operation
@ -13,21 +13,20 @@ class FernetDecrypt extends Operation {
/** /**
* FernetDecrypt constructor * FernetDecrypt constructor
*/ */
constructor() { constructor() {
super(); super();
this.name = 'Fernet Decrypt'; this.name = "Fernet Decrypt";
this.module = 'Default'; this.module = "Default";
this.description = 'Fernet is a symmetric encryption method which makes sure that the message encrypted cannot be manipulated/read without the key. It uses URL safe encoding for the keys. Fernet uses 128-bit AES in CBC mode and PKCS7 padding, with HMAC using SHA256 for authentication. The IV is created from os.random().'; this.description = "Fernet is a symmetric encryption method which makes sure that the message encrypted cannot be manipulated/read without the key. It uses URL safe encoding for the keys. Fernet uses 128-bit AES in CBC mode and PKCS7 padding, with HMAC using SHA256 for authentication. The IV is created from os.random().";
this.infoURL = 'https://asecuritysite.com/encryption/fer'; this.infoURL = "https://asecuritysite.com/encryption/fer";
this.inputType = 'string'; this.inputType = "string";
this.outputType = 'string'; this.outputType = "string";
this.args = [ this.args = [
{ {
'name': 'Secret', "name": "Secret",
'type': 'string', "type": "string",
'value': "" "value": ""
}, },
]; ];
this.patterns = [ this.patterns = [
@ -45,12 +44,12 @@ class FernetDecrypt extends Operation {
*/ */
run(input, args) { run(input, args) {
const [secretInput] = args; const [secretInput] = args;
var fernet = require('fernet'); const fernet = require("fernet");
var secret = new fernet.Secret(secretInput); const secret = new fernet.Secret(secretInput);
var token = new fernet.Token({ const token = new fernet.Token({
secret: secret, secret: secret,
token: input token: input
}) });
return token.decode(); return token.decode();
} }
} }

View File

@ -4,7 +4,7 @@
* @license Apache-2.0 * @license Apache-2.0
*/ */
import Operation from '../Operation'; import Operation from "../Operation";
/** /**
* FernetEncrypt operation * FernetEncrypt operation
@ -13,21 +13,20 @@ class FernetEncrypt extends Operation {
/** /**
* FernetEncrypt constructor * FernetEncrypt constructor
*/ */
constructor() { constructor() {
super(); super();
this.name = 'Fernet Encrypt'; this.name = "Fernet Encrypt";
this.module = 'Default'; this.module = "Default";
this.description = 'Fernet is a symmetric encryption method which makes sure that the message encrypted cannot be manipulated/read without the key. It uses URL safe encoding for the keys. Fernet uses 128-bit AES in CBC mode and PKCS7 padding, with HMAC using SHA256 for authentication. The IV is created from os.random().'; this.description = "Fernet is a symmetric encryption method which makes sure that the message encrypted cannot be manipulated/read without the key. It uses URL safe encoding for the keys. Fernet uses 128-bit AES in CBC mode and PKCS7 padding, with HMAC using SHA256 for authentication. The IV is created from os.random().";
this.infoURL = 'https://asecuritysite.com/encryption/fer'; this.infoURL = "https://asecuritysite.com/encryption/fer";
this.inputType = 'string'; this.inputType = "string";
this.outputType = 'string'; this.outputType = "string";
this.args = [ this.args = [
{ {
'name': 'Secret', "name": "Secret",
'type': 'string', "type": "string",
'value': "" "value": ""
}, },
]; ];
} }
@ -38,11 +37,11 @@ class FernetEncrypt extends Operation {
*/ */
run(input, args) { run(input, args) {
const [secretInput] = args; const [secretInput] = args;
var fernet = require('fernet'); const fernet = require("fernet");
var secret = new fernet.Secret(secretInput); const secret = new fernet.Secret(secretInput);
var token = new fernet.Token({ const token = new fernet.Token({
secret: secret, secret: secret,
}) });
return token.encode(input); return token.encode(input);
} }
} }

View File

@ -4,7 +4,8 @@
* @license Apache-2.0 * @license Apache-2.0
*/ */
import Operation from '../Operation'; import Operation from "../Operation";
import OperationError from "../errors/OperationError";
/** /**
* Malbolge operation * Malbolge operation
@ -13,27 +14,26 @@ class Malbolge extends Operation {
/** /**
* Malbolge constructor * Malbolge constructor
*/ */
constructor () { constructor () {
super(); super();
this.name = 'Malbolge'; this.name = "Malbolge";
this.module = 'Default'; this.module = "Default";
this.description = 'Malbolge, invented by Ben Olmstead in 1998, is an esoteric programming language designed to be as difficult to program in as possible. The first Hello, world! program written in it was produced by a Lisp program using a local beam search of the space of all possible programs. It is modeled as a virtual machine based on ternary digits.'; this.description = "Malbolge, invented by Ben Olmstead in 1998, is an esoteric programming language designed to be as difficult to program in as possible. The first Hello, world! program written in it was produced by a Lisp program using a local beam search of the space of all possible programs. It is modeled as a virtual machine based on ternary digits.";
this.infoURL = 'http://esolangs.org/wiki/Malbolge'; this.infoURL = "http://esolangs.org/wiki/Malbolge";
this.inputType = 'string'; this.inputType = "string";
this.outputType = 'string'; this.outputType = "string";
this.args = [ this.args = [
{ {
'name': 'User Input (line by line)', "name": "User Input (line by line)",
'type': 'text', "type": "text",
'value': '' "value": ""
} }
]; ];
this.patterns = [ this.patterns = [
{ {
match: '^(?:[\\x21-\\x7e])?$', match: "^(?:[\\x21-\\x7e])?$",
flags: 'i', flags: "i",
args: [] args: []
} }
]; ];
@ -48,34 +48,37 @@ class Malbolge extends Operation {
const [userInput] = args; const [userInput] = args;
const EOF = 59048; const EOF = 59048;
var mb = require('malbolge-vm'), const mb = require("malbolge-vm");
vm = mb.load(input), const vm = mb.load(input);
temp, const userInputLines = userInput.split("\n");
userInputLines = userInput.split('\n'), const inputLoop = true;
let temp,
userInputIndex = 0, userInputIndex = 0,
output = ''; output = "";
while (true) { while (inputLoop) {
try { try {
while ((temp = mb.step(vm)) !== mb.EXIT) { while ((temp = mb.step(vm)) !== mb.EXIT) {
if (temp !== null) { output += String.fromCharCode(temp); } if (temp !== null) {
output += String.fromCharCode(temp);
}
} }
break; break;
} catch (e) { } catch (e) {
if (e === mb.WANTS_INPUT) { if (e === mb.WANTS_INPUT) {
var txt; let txt;
if (userInputIndex < userInputLines.length) { if (userInputIndex < userInputLines.length) {
txt = userInputLines[userInputIndex]; txt = userInputLines[userInputIndex];
userInputIndex++; userInputIndex++;
} else { } else {
txt = window.prompt('User input expected', ''); txt = window.prompt("User input expected", "");
} }
for (var i = 0; i < txt.length; i++) { for (let i = 0; i < txt.length; i++) {
mb.step(vm, txt.charCodeAt(i)); mb.step(vm, txt.charCodeAt(i));
} }
mb.step(vm, EOF); mb.step(vm, EOF);
} else { } else {
console.log('Error: ' + e); throw new OperationError(`Error: ${e}`);
} }
} }
break; break;