class MorseCodeCipher {
constructor() {
// This is a JavaScript implementation of MorseCode Cipher
this.morse_dict = {
'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': '--..',
'1': '.----', '2': '..---', '3': '...--',
'4': '....-', '5': '.....', '6': '-....',
'7': '--...', '8': '---..', '9': '----.',
'0': '-----', ',': '--..--', '.': '.-.-.-',
'?': '..--..', ' ': '/', '-': '-....-',
'(': '-.--.', ')': '-.--.-'
};
this.reverse_morse = {};
for (const [key, value] of Object.entries(this.morse_dict)) {
this.reverse_morse[value] = key;
}
}
encrypt(text) {
let result = '';
for (const ch of text.toUpperCase()) {
result += this.morse_dict[ch] || ch;
result += ' ';
}
return result.trim();
}
decrypt(text) {
let result = '';
for (const code of text.split(' ')) {
result += this.reverse_morse[code] || code;
}
return result;
}
}
(async ()=>{
const cipher = new MorseCodeCipher();
require("jsshort")
let work = await input("For decrypt 0 For encrypt enter any key: ")
if(work != '0'){
const plainText = await input("Enter text to encrypt: ")
const encryptedText = cipher.encrypt(plainText);
console.log('Encrypted Text:', encryptedText);
} else {
let enc = await input("Enter text to decrypt: ")
const decryptedText = cipher.decrypt(enc);
console.log('Decrypted Text:', decryptedText);
}
process.exit(0)
})()❤1
🌴 The Complete Front-End Web Development Course 🌴
⬇️ Download Link :-
https://mega.nz/folder/7z4wiJ4K#\_tOW2PH0-XxXVdgEn371ow
✅ Join For More: https://t.me/addlist/UTxZqUCuoM9jYjZl
⬇️ Download Link :-
https://mega.nz/folder/7z4wiJ4K#\_tOW2PH0-XxXVdgEn371ow
✅ Join For More: https://t.me/addlist/UTxZqUCuoM9jYjZl
mega.nz
File folder on MEGA
// 1. push()
let arrPush = [1, 2, 3];
arrPush.push(4, 5);
console.log(arrPush); // Output: [1, 2, 3, 4, 5]
// 2. pop()
let arrPop = [1, 2, 3, 4, 5];
let popped = arrPop.pop();
console.log(popped); // Output: 5
console.log(arrPop); // Output: [1, 2, 3, 4]
// 3. shift()
let arrShift = [1, 2, 3, 4, 5];
let shifted = arrShift.shift();
console.log(shifted); // Output: 1
console.log(arrShift); // Output: [2, 3, 4, 5]
// 4. unshift()
let arrUnshift = [1, 2, 3];
arrUnshift.unshift(-3, -2, -1, 0);
console.log(arrUnshift); // Output: [-3, -2, -1, 0, 1, 2, 3]
// 5. splice()
let arrSplice = [1, 2, 3, 4, 5];
arrSplice.splice(2, 1, 'a', 'b');
console.log(arrSplice); // Output: [1, 2, 'a', 'b', 4, 5]
// 6. slice()
let arrSlice = [1, 2, 3, 4, 5];
let sliced = arrSlice.slice(1, 4);
console.log(sliced); // Output: [2, 3, 4]