// Cipher programs // Author: xamidev // Licensed under the Unlicense. See the repo below. // https://github.com/xamidev/blankos #include "../libc/stdio.h" #include "ciphers.h" #include "../libc/string.h" #include void rot13(char* input, char* output) { int i = 0; while (input[i] != '\0') { char c = input[i]; if (c >= 'a' && c <= 'z') { output[i] = ((c - 'a' + 13) % 26) + 'a'; } else if (c >= 'A' && c <= 'Z') { output[i] = ((c - 'A' + 13) % 26) + 'A'; } else { output[i] = c; } i++; } output[i] = '\0'; } void program_rot13(int argc, char* argv[]) { if (argc < 2) { printf("Usage: %s \n", argv[0]); return; } char input_buffer[BUFFER_SIZE] = {0}; char output[BUFFER_SIZE] = {0}; for (int i=1; i= 'a' && c <= 'z') { const char* morse_code = morse_alphabet[c - 'a']; int j = 0; while (morse_code[j] != '\0') { output[pos++] = morse_code[j++]; } } else if (c >= 'A' && c <= 'Z') { const char* morse_code = morse_alphabet[c - 'A']; int j = 0; while (morse_code[j] != '\0') { output[pos++] = morse_code[j++]; } } else if (c >= '0' && c <= '9') { const char* morse_code = morse_digits[c - '0']; int j = 0; while (morse_code[j] != '\0') { output[pos++] = morse_code[j++]; } } else if (c == ' ') { output[pos++] = ' '; } output[pos++] = ' '; i++; } if (pos > 0) { output[pos - 1] = '\0'; } else { output[pos] = '\0'; } } void program_morse(int argc, char* argv[]) { if (argc < 2) { printf("Usage: %s \n", argv[0]); return; } char output[512]; char message[BUFFER_SIZE]; for (int i=1; i