Шифрование сообщения в javascript
У меня возникли проблемы с поиском способа принимать входные данные пользователей и перебирать различные библиотеки, которые я создал в качестве глобальных переменных.
/b>
Что я уже пробовал:
/*GLOBAL VARIABLES*/ /* asks for the code you will encrypt into*/ var CODE = readLine("Which code would you like to encode in? morse, tap, ascii, binary, phonetic, substitution, or decode (Pick One: lowercase, NO symbols)"); /*I want this to loop and ask for one character at a time to encrypt against the libraries.*/ var MESSAGE = readLine("Message(*UPPERCASE ONLY*): "); /*FORMAT: SPACE 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 ARRAY: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36*/ //USED TO ASSIGN AN INDEX NUMBER TO MESSAGE BEING ENCODED, EX. CODE: morse, MESSAGE: A, INDEX: 1 RETURNS: ._ var MIDX = [" ", "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 ]; var MORSE = [" ", "._", "_...", "_._.", "_..", ".", ".._.", "__.", "....", "..", ".___", "_._", "._..", "__", "_.", "___", ".__.", "__._", "._.", "...", "_", ".._", "..._", ".__", "_.._", "_.__", "__..", ".____", "..___", "...__", "...._", ".....", "_....", "__...", "___..", "____.", "_____" ]; function start(){ if(CODE == "morse"){ var me = morseEncode(); println(me); }else{ println("Sorry, Code language selected is not a valid input. Please try again."); } } function morseEncode(){ var encoded = []; for(var i = 0; i < .length; i++){ } return encoded; }
Richard MacCutchan
Фу!