mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-10 00:05:11 -04:00
Add new module: Convert to Emoji alphabe
This is a fun 'cipher' for kids. Converts characters to their representation in the Emoji animal alphabet, matching first letters of the animal. Can be combined with 'Generate QR Code'. Example: 🐅 🐙 🐧 🐍 🐘 ℃ 🐀 🐘 🐅 ❗️
This commit is contained in:
parent
c9d9730726
commit
ae5c7daf8b
4 changed files with 125 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -12,3 +12,4 @@ src/node/index.mjs
|
||||||
**/*.DS_Store
|
**/*.DS_Store
|
||||||
tests/browser/output/*
|
tests/browser/output/*
|
||||||
|
|
||||||
|
package-lock.json
|
||||||
|
|
|
@ -202,7 +202,8 @@
|
||||||
"Decode text",
|
"Decode text",
|
||||||
"Remove Diacritics",
|
"Remove Diacritics",
|
||||||
"Unescape Unicode Characters",
|
"Unescape Unicode Characters",
|
||||||
"Convert to NATO alphabet"
|
"Convert to NATO alphabet",
|
||||||
|
"Convert to Emoji alphabet"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
89
src/core/operations/ConvertToEmojiAlphabet.mjs
Normal file
89
src/core/operations/ConvertToEmojiAlphabet.mjs
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
/**
|
||||||
|
* @author Arnim Rupp https://github.com/2d4d/crypto_puzzles
|
||||||
|
* @copyright Crown Copyright 2020
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert to Emoji alphabet operation
|
||||||
|
*/
|
||||||
|
class ConvertToEmojiAlphabet extends Operation {
|
||||||
|
/**
|
||||||
|
* ConvertToEmojiAlphabet constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "Convert to Emoji alphabet";
|
||||||
|
this.module = "Default";
|
||||||
|
this.description = "This is a fun 'cipher' for kids. Converts characters to their representation in the Emoji animal alphabet, matching first letters of the animal. Can be combined with 'Generate QR Code'.";
|
||||||
|
this.infoURL = "https://en.wikipedia.org/wiki/Emoji";
|
||||||
|
this.inputType = "string";
|
||||||
|
this.outputType = "string";
|
||||||
|
this.args = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
return input.replace(/[a-z0-9,.\-+*#?! ]/ig, letter => {
|
||||||
|
return lookup[letter.toUpperCase()];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const lookup = {
|
||||||
|
"A": "🐜 ",
|
||||||
|
"B": "🐻 ",
|
||||||
|
"C": "℃ ",
|
||||||
|
"D": "🐬 ",
|
||||||
|
"E": "🐘 ",
|
||||||
|
"F": "🦊 ",
|
||||||
|
"G": "🦒 ",
|
||||||
|
"H": "🐹 ",
|
||||||
|
"I": "ℹ️ ",
|
||||||
|
"J": "ʝ ",
|
||||||
|
"K": "🦘 ",
|
||||||
|
"L": "🦁 ",
|
||||||
|
"M": "🐁 ",
|
||||||
|
"N": "ℕ ",
|
||||||
|
"O": "🐙 ",
|
||||||
|
"P": "🐧 ",
|
||||||
|
"Q": "🂭 ",
|
||||||
|
"R": "🐀 ",
|
||||||
|
"S": "🐍 ",
|
||||||
|
"T": "🐅 ",
|
||||||
|
"U": "ᶙ ",
|
||||||
|
"V": "✌ ",
|
||||||
|
"W": "🐋 ",
|
||||||
|
"X": "⚔️ ",
|
||||||
|
"Y": "¥ ",
|
||||||
|
"Z": "🦓 ",
|
||||||
|
"0": "🅾️ ",
|
||||||
|
"1": "🥇 ",
|
||||||
|
"2": "⚁ ",
|
||||||
|
"3": "ᗱ ",
|
||||||
|
"4": "༥ ",
|
||||||
|
"5": "⚄ ",
|
||||||
|
"6": "🃖 ",
|
||||||
|
"7": "ㇴ ",
|
||||||
|
"8": "🎱 ",
|
||||||
|
"9": "9️⃣ ",
|
||||||
|
"+": "➕ ",
|
||||||
|
"-": "➖ ",
|
||||||
|
"#": "#️⃣ ",
|
||||||
|
"*": "✳️ ",
|
||||||
|
".": ". ",
|
||||||
|
",": ", ",
|
||||||
|
" ": " ",
|
||||||
|
"?": "<22> ",
|
||||||
|
"!": "❗️ "
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ConvertToEmojiAlphabet;
|
33
tests/operations/tests/ConvertToEmojiAlphabet.mjs
Normal file
33
tests/operations/tests/ConvertToEmojiAlphabet.mjs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/**
|
||||||
|
* @author Arnim Rupp https://github.com/2d4d/crypto_puzzles
|
||||||
|
* @copyright Crown Copyright 2020
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import TestRegister from "../../lib/TestRegister.mjs";
|
||||||
|
|
||||||
|
TestRegister.addTests([
|
||||||
|
{
|
||||||
|
name: "Convert to Emoji alphabet: nothing",
|
||||||
|
input: "",
|
||||||
|
expectedOutput: "",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Convert to Emoji alphabet",
|
||||||
|
args: []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Convert to Emoji alphabet: full alphabet with numbers",
|
||||||
|
input: "abcdefghijklmnopqrstuvwxyz1234567890,.-#+*-",
|
||||||
|
expectedOutput: "🐜 🐻 ℃ 🐬 🐘 🦊 🦒 🐹 ℹ️ ʝ 🦘 🦁 🐁 ℕ 🐙 🐧 🂭 🐀 🐍 🐅 ᶙ ✌ 🐋 ⚔️ ¥ 🦓 🥇 ⚁ ᗱ ༥ ⚄ 🃖 ㇴ 🎱 9️⃣ 🅾️ , . ➖ #️⃣ ➕ ✳️ ➖ ",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Convert to Emoji alphabet",
|
||||||
|
args: []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]);
|
Loading…
Add table
Add a link
Reference in a new issue