HZROT.cpp:
#include "HZROT.h"
std::string ROTEncode(std::string instring, int rot)
{
std::string result;
for (char a : instring)
{
if (a >= 'A' && a <= 'Z')
result += ((int)a + rot) % (int)'Z';
else if (a >= 'a' && a <= 'z')
result += ((int)a + rot) % (int)'z';
else
result += a;
}
return result;
}
std::string ROTDecode(std::string instring, int rot)
{
std::string result;
for (char a : instring)
{
if (a >= 'A' && a <= 'Z')
result += ((int)a - rot + (int)'Z') % (int)'Z';
else if (a >= 'a' && a <= 'z')
result += ((int)a - rot + (int)'z') % (int)'z';
else
result += a;
}
return result;
}
HZROT.h:
#include <string>
std::string ROTEncode(std::string instring, int rot);
std::string ROTDecode(std::string instring, int rot);
I use this code to encrypt/decrypt ROT, but it doesn't work correctly: Command line:
C:\Users\adm1n\Desktop\C\HZToolkit>hztoolkit --erot 13 abcdefghijklmnopqrstuvwyz
Outputs: nopqrstuvwxy
So it doesn't work with letters after 'l'. Can you help me?