Update Ciphers.mjs

Added a method called getMultiTapMap() which takes the arguments of toggle{int} and space_delim {string}.
This function creates a dictionary for the Multi Tap Cipher Encoding Scheme.
If the toggle is 1, it returns the dictionary directly.
else it reverses the dictionary and returns it, enabling it to be used in the decode operation.
This commit is contained in:
Kaustubh BM 2021-05-14 18:29:39 +05:30 committed by GitHub
parent 2f600f1dbf
commit ae5bc9c5b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 0 deletions

View File

@ -65,6 +65,27 @@ export function genPolybiusSquare (keyword) {
return polybius;
}
/**
* Generates a mapping for the MultiTap
*
* @private
* @author Necron3574 [kaustubhbm3574@gmail.com]
* @param {int,string} toggle - 1 for encode , 2 for decode, space_delim
* @returns {dict}
*/
export function getMultiTapMap (toggle,space_delim) {
var mapping = {"A" :"2","B":"22","C":"222","D":"3","E":"33","F":"333","G":"4","H":"44","I":"444","J":"5","K":"55","L":"555","M":"6","N":"66","O":"666","P":"7","Q":"77","R":"777","S":"7777","T":"8","U":"88","V":"888","W":"9","X":"99","Y":"999","Z":"9999"," ":space_delim};
if(toggle == 1)
return mapping;
else{
var ret = {};
for(var key in mapping){
ret[mapping[key]] = key;
}
return ret;
}
}
/**
* A mapping of string formats to their classes in the CryptoJS library.
*