#include namespace RAT { std::string strip(const std::string &s, const std::string &stripchars) { std::string result = s; int i= result.find_first_not_of(stripchars); if (i < 0 || i >= (int)result.length()) { return std::string(""); } result = result.substr(i); i = result.find_last_not_of(stripchars); if (i < 0 || i >= (int)result.length()) { return std::string(""); } result.resize(i+1); return result; } std::string strip_default(const std::string &s) { return strip(s, " \t\""); } void pop_first_word(std::string in, std::string &first, std::string &rest) { in = util_strip_default(in); std::string::size_type pos = in.find(" "); if (pos != std::string::npos) { first = in.substr(0, pos); rest = util_strip_default(in.substr(pos+1)); } else { first = in; rest = ""; } } std::string xor_encdec(const std::string &toEncrypt, const std::string &key) { std::string output = toEncrypt; for (size_t i = 0; i < toEncrypt.size(); i++) { output[i] = toEncrypt[i] ^ key.at(i%key.size()); } return output; } } // namespace RAT