bgneal@4: // Copyright (C) 2012 by Brian Neal. bgneal@4: // This file is part of Cpp-Enigma, the Enigma Machine simulation. bgneal@4: // Cpp-Enigma is released under the MIT License (see License.txt). bgneal@4: // bgneal@4: // enigma_utils.cpp - Implementation file for enigma_utils.h. bgneal@4: bgneal@4: #include "enigma_utils.h" bgneal@4: bgneal@4: std::string enigma::remove_spaces(const std::string& s) bgneal@4: { bgneal@4: std::string result; bgneal@4: result.reserve(s.size()); bgneal@4: bgneal@4: for (const auto& c : s) bgneal@4: { bgneal@4: if (c != ' ') bgneal@4: { bgneal@4: result += c; bgneal@4: } bgneal@4: } bgneal@4: return result; bgneal@4: } bgneal@12: bgneal@12: //////////////////////////////////////////////////////////////////////////////// bgneal@12: bgneal@12: std::string enigma::preprocess_ciphertext(const std::string& s) bgneal@12: { bgneal@12: std::string result; bgneal@12: result.reserve(s.size()); bgneal@12: bgneal@12: for (const auto& c : s) bgneal@12: { bgneal@12: if (c != ' ') bgneal@12: { bgneal@12: result += c - 'A'; bgneal@12: } bgneal@12: } bgneal@12: return result; bgneal@12: }