2018-08-22 21:24:32 +02:00
|
|
|
/**
|
|
|
|
* Base85 resources.
|
|
|
|
*
|
|
|
|
* @author PenguinGeorge [george@penguingeorge.com]
|
|
|
|
* @copyright Crown Copyright 2018
|
|
|
|
* @license Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Base85 alphabet options.
|
|
|
|
*/
|
|
|
|
export const ALPHABET_OPTIONS = [
|
|
|
|
{
|
|
|
|
name: "Standard",
|
2018-08-23 23:05:31 +02:00
|
|
|
value: "!-u",
|
2018-08-22 21:24:32 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Z85 (ZeroMQ)",
|
2018-08-23 23:56:18 +02:00
|
|
|
value: "0-9a-zA-Z.\\-:+=^!/*?&<>()[]{}@%$#",
|
2018-08-22 21:24:32 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "IPv6",
|
2018-08-23 23:05:31 +02:00
|
|
|
value: "0-9A-Za-z!#$%&()*+\\-;<=>?@^_`{|~}",
|
2018-08-22 21:24:32 +02:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the name of the alphabet, when given the alphabet.
|
|
|
|
*
|
|
|
|
* @param {string} alphabet
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
export function alphabetName(alphabet) {
|
|
|
|
alphabet = alphabet.replace("'", "'");
|
|
|
|
alphabet = alphabet.replace("\"", """);
|
|
|
|
alphabet = alphabet.replace("\\", "\");
|
|
|
|
let name;
|
|
|
|
|
|
|
|
ALPHABET_OPTIONS.forEach(function(a) {
|
|
|
|
if (escape(alphabet) === escape(a.value)) name = a.name;
|
|
|
|
});
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|