bgneal@1: #ifndef CPP_ENIGMA_ENIGMA_UTILS_H bgneal@1: #define CPP_ENIGMA_ENIGMA_UTILS_H bgneal@1: // Copyright (C) 2012 by Brian Neal. bgneal@1: // This file is part of Cpp-Enigma, the Enigma Machine simulation. bgneal@1: // Cpp-Enigma is released under the MIT License (see License.txt). bgneal@1: // bgneal@1: // enigma_utils.h - This file contains common functions used throughout Cpp-Enigma. bgneal@1: bgneal@4: #include bgneal@4: bgneal@1: namespace enigma bgneal@1: { bgneal@1: // This version of mod acts like Python's with respect to negative dividends. bgneal@1: inline int alpha_mod(int dividend) bgneal@1: { bgneal@1: if (dividend < 0) bgneal@1: { bgneal@1: dividend += 26; bgneal@1: } bgneal@1: return dividend % 26; bgneal@1: } bgneal@4: bgneal@4: // Removes spaces from a string and returns the resulting string: bgneal@4: std::string remove_spaces(const std::string& s); bgneal@12: bgneal@12: // Removes spaces & converts to signal numbers: bgneal@12: std::string preprocess_ciphertext(const std::string& s); bgneal@1: } bgneal@1: bgneal@1: #endif