Various fixes

This commit is contained in:
Tim Stallard 2017-04-05 17:06:06 +01:00
parent c5c73e76b5
commit f583284e18
5 changed files with 8 additions and 8 deletions

View File

@ -26,10 +26,10 @@ module.exports = {
.map((num)=>((num%52)+52)%52)
.map((num)=>{
if(num < 26){
asciiOffset = 97;
var asciiOffset = 97;
}
else{
asciiOffset = 65 - 26;
var asciiOffset = 65 - 26;
}
return num + asciiOffset;
})

View File

@ -9,8 +9,8 @@ function getFactors(num){
}
function coPrime(a, b){
aFactors = getFactors(a);
bFactors = getFactors(b);
var aFactors = getFactors(a);
var bFactors = getFactors(b);
var common = aFactors.filter((factor)=>(bFactors.indexOf(factor) > -1));
return (common.length == 0);

View File

@ -21,7 +21,7 @@ module.exports = {
return cipherText
.split("")
.map(require("./util/toNum.js"))
.map((int, pos, ints)=>{
.map(function(int, pos, ints){
if(Number.isInteger(int)){
this.i++;
return (int + 26 - keyNums[this.i%key.length])%26;

View File

@ -24,7 +24,7 @@ module.exports = {
.map(function(int, pos, ints){
if(Number.isInteger(int)){
this.i++;
return val = (int + keyNums[this.i % key.length]) % 26;
return (int + keyNums[this.i % key.length]) % 26;
}
else{
return int;

View File

@ -7,7 +7,7 @@ module.exports = {
},
number: function(input){
if(isNaN(parseInt(input))){
throw "Invalid input type - should be a string.";
throw "Invalid input type - should be a number.";
}
return parseInt(input);
}