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
*/
import Operation from '../Operation';
import OperationError from "../errors/OperationError";
import Operation from "../Operation";
/**
* BaconCipherDecode operation
@ -14,31 +13,30 @@ class BaconCipherDecode extends Operation {
/**
* BaconCipherDecode constructor
*/
constructor() {
super();
this.name = 'Bacon Cipher Decode';
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.infoURL = 'https://en.wikipedia.org/wiki/Bacon%27s_cipher';
this.inputType = 'string';
this.outputType = 'string';
this.name = "Bacon Cipher Decode";
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.infoURL = "https://en.wikipedia.org/wiki/Bacon%27s_cipher";
this.inputType = "string";
this.outputType = "string";
this.args = [
{
'name': 'Alphabet',
'type': 'option',
'value': ['ABCDEFGHIKLMNOPQRSTUWXYZ', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ']
"name": "Alphabet",
"type": "option",
"value": ["ABCDEFGHIKLMNOPQRSTUWXYZ", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
},
{
'name': 'Translation',
'type': 'option',
'value': ['0/1', 'A/B', 'Case', 'A-M/N-Z']
"name": "Translation",
"type": "option",
"value": ["0/1", "A/B", "Case", "A-M/N-Z"]
},
{
'name': 'Invert Translation',
'type': 'boolean',
'value': false
"name": "Invert Translation",
"type": "boolean",
"value": false
}
];
}
@ -53,27 +51,26 @@ class BaconCipherDecode extends Operation {
const regexAM = /[A-M]/;
const regexNZ = /[N-Z]/;
// split text into groups of 5 characters
var groups = [];
var group = "";
const groups = [];
let group = "";
for (let index = 0; index < input.length; index++) {
const char = input[index];
console.log(char);
if (char.toLowerCase() != char.toUpperCase()) {
if (char.toLowerCase() !== char.toUpperCase()) {
switch (translation) {
case "0/1":
group = group + char;
break;
case "A/B":
if (char == "A") {
if (char === "A") {
group = group + "1";
} else if (char == "B") {
} else if (char === "B") {
group = group + "0";
}
break;
case "Case":
if (char == char.toUpperCase()) {
if (char === char.toUpperCase()) {
group = group + "1";
} else {
group = group + "0";
@ -82,16 +79,15 @@ class BaconCipherDecode extends Operation {
case "A-M/N-Z":
if (char.match(regexAM)) {
group = group + "1";
}
else if (char.match(regexNZ)) {
group = group + "0"
} else if (char.match(regexNZ)) {
group = group + "0";
}
break;
default:
break;
}
if (group.length == 5) {
if (group.length === 5) {
groups.push(group);
group = "";
}
@ -107,25 +103,25 @@ class BaconCipherDecode extends Operation {
let output = "";
const byteLen = 5;
for (let index = 0; index < groups.length; index++) {
var group = groups[index];
let group = groups[index];
if (invert) {
group = group.replace(/[01]/g, function (m) {
return {
'0': '1',
'1': '0'
"0": "1",
"1": "0"
}[m];
});
}
// calculate binary value
var number;
let number;
for (let i = 0; i < group.length; i += byteLen) {
number = parseInt(group.substr(i, byteLen), 2);
}
var char;
let char;
if (number < alphabet.length) {
char = alphabet[number];
} else {
char = "?"
char = "?";
}
output += char;
}

View File

@ -4,7 +4,7 @@
* @license Apache-2.0
*/
import Operation from '../Operation';
import Operation from "../Operation";
/**
* Brainfuck operation
@ -13,21 +13,20 @@ class Brainfuck extends Operation {
/**
* Brainfuck constructor
*/
constructor () {
super();
this.name = 'Brainfuck';
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.infoURL = 'http://esolangs.org/wiki/Brainfuck';
this.inputType = 'string';
this.outputType = 'string';
this.name = "Brainfuck";
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.infoURL = "http://esolangs.org/wiki/Brainfuck";
this.inputType = "string";
this.outputType = "string";
this.args = [
{
'name': 'User Input',
'type': 'text',
'value': ''
"name": "User Input",
"type": "text",
"value": ""
}
];
}
@ -39,8 +38,8 @@ class Brainfuck extends Operation {
*/
run (input, args) {
const [userInput] = args;
var brainfuck = require('brainfuck-javascript');
let output = brainfuck.text(input, userInput);
const brainfuck = require("brainfuck-javascript");
const output = brainfuck.text(input, userInput);
return output;
}
}

View File

@ -4,7 +4,7 @@
* @license Apache-2.0
*/
import Operation from '../Operation';
import Operation from "../Operation";
/**
* FernetDecrypt operation
@ -13,21 +13,20 @@ class FernetDecrypt extends Operation {
/**
* FernetDecrypt constructor
*/
constructor() {
super();
this.name = 'Fernet Decrypt';
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.infoURL = 'https://asecuritysite.com/encryption/fer';
this.inputType = 'string';
this.outputType = 'string';
this.name = "Fernet Decrypt";
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.infoURL = "https://asecuritysite.com/encryption/fer";
this.inputType = "string";
this.outputType = "string";
this.args = [
{
'name': 'Secret',
'type': 'string',
'value': ""
"name": "Secret",
"type": "string",
"value": ""
},
];
this.patterns = [
@ -45,12 +44,12 @@ class FernetDecrypt extends Operation {
*/
run(input, args) {
const [secretInput] = args;
var fernet = require('fernet');
var secret = new fernet.Secret(secretInput);
var token = new fernet.Token({
const fernet = require("fernet");
const secret = new fernet.Secret(secretInput);
const token = new fernet.Token({
secret: secret,
token: input
})
});
return token.decode();
}
}

View File

@ -4,7 +4,7 @@
* @license Apache-2.0
*/
import Operation from '../Operation';
import Operation from "../Operation";
/**
* FernetEncrypt operation
@ -13,21 +13,20 @@ class FernetEncrypt extends Operation {
/**
* FernetEncrypt constructor
*/
constructor() {
super();
this.name = 'Fernet Encrypt';
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.infoURL = 'https://asecuritysite.com/encryption/fer';
this.inputType = 'string';
this.outputType = 'string';
this.name = "Fernet Encrypt";
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.infoURL = "https://asecuritysite.com/encryption/fer";
this.inputType = "string";
this.outputType = "string";
this.args = [
{
'name': 'Secret',
'type': 'string',
'value': ""
"name": "Secret",
"type": "string",
"value": ""
},
];
}
@ -38,11 +37,11 @@ class FernetEncrypt extends Operation {
*/
run(input, args) {
const [secretInput] = args;
var fernet = require('fernet');
var secret = new fernet.Secret(secretInput);
var token = new fernet.Token({
const fernet = require("fernet");
const secret = new fernet.Secret(secretInput);
const token = new fernet.Token({
secret: secret,
})
});
return token.encode(input);
}
}

View File

@ -4,7 +4,8 @@
* @license Apache-2.0
*/
import Operation from '../Operation';
import Operation from "../Operation";
import OperationError from "../errors/OperationError";
/**
* Malbolge operation
@ -13,27 +14,26 @@ class Malbolge extends Operation {
/**
* Malbolge constructor
*/
constructor () {
super();
this.name = 'Malbolge';
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.infoURL = 'http://esolangs.org/wiki/Malbolge';
this.inputType = 'string';
this.outputType = 'string';
this.name = "Malbolge";
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.infoURL = "http://esolangs.org/wiki/Malbolge";
this.inputType = "string";
this.outputType = "string";
this.args = [
{
'name': 'User Input (line by line)',
'type': 'text',
'value': ''
"name": "User Input (line by line)",
"type": "text",
"value": ""
}
];
this.patterns = [
{
match: '^(?:[\\x21-\\x7e])?$',
flags: 'i',
match: "^(?:[\\x21-\\x7e])?$",
flags: "i",
args: []
}
];
@ -48,34 +48,37 @@ class Malbolge extends Operation {
const [userInput] = args;
const EOF = 59048;
var mb = require('malbolge-vm'),
vm = mb.load(input),
temp,
userInputLines = userInput.split('\n'),
const mb = require("malbolge-vm");
const vm = mb.load(input);
const userInputLines = userInput.split("\n");
const inputLoop = true;
let temp,
userInputIndex = 0,
output = '';
output = "";
while (true) {
while (inputLoop) {
try {
while ((temp = mb.step(vm)) !== mb.EXIT) {
if (temp !== null) { output += String.fromCharCode(temp); }
if (temp !== null) {
output += String.fromCharCode(temp);
}
}
break;
} catch (e) {
if (e === mb.WANTS_INPUT) {
var txt;
let txt;
if (userInputIndex < userInputLines.length) {
txt = userInputLines[userInputIndex];
userInputIndex++;
} 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, EOF);
} else {
console.log('Error: ' + e);
throw new OperationError(`Error: ${e}`);
}
}
break;