std::map<uint8_t, char> a1z26_decrypt_map = {
34{1,
'a'}, {2,
'b'}, {3,
'c'}, {4,
'd'}, {5,
'e'}, {6,
'f'}, {7,
'g'},
35{8,
'h'}, {9,
'i'}, {10,
'j'}, {11,
'k'}, {12,
'l'}, {13,
'm'}, {14,
'n'},
36{15,
'o'}, {16,
'p'}, {17,
'q'}, {18,
'r'}, {19,
's'}, {20,
't'}, {21,
'u'},
37{22,
'v'}, {23,
'w'}, {24,
'x'}, {25,
'y'}, {26,
'z'},
40std::map<char, uint8_t> a1z26_encrypt_map = {
41{
'a', 1}, {
'b', 2}, {
'c', 3}, {
'd', 4}, {
'e', 5}, {
'f', 6}, {
'g', 7},
42{
'h', 8}, {
'i', 9}, {
'j', 10}, {
'k', 11}, {
'l', 12}, {
'm', 13}, {
'n', 14},
43{
'o', 15}, {
'p', 16}, {
'q', 17}, {
'r', 18}, {
's', 19}, {
't', 20}, {
'u', 21},
44{
'v', 22}, {
'w', 23}, {
'x', 24}, {
'y', 25}, {
'z', 26}};
53std::transform(text.begin(), text.end(), text.begin(),
55std::replace(text.begin(), text.end(),
':',
' ');
56 for(
charletter : text) {
58result += std::to_string(
59a1z26_encrypt_map[letter]);
78std::string
decrypt(
conststd::string& text,
boolbReturnUppercase =
false) {
82std::vector<std::string> word_array;
83std::stringstream sstream(text);
85 while(sstream >> word) {
86word_array.push_back(word);
89 for(
auto& i : word_array) {
90std::replace(i.begin(), i.end(),
'-',
' ');
91std::vector<std::string> text_array;
93std::stringstream ss(i);
95 while(ss >> res_text) {
96text_array.push_back(res_text);
99 for(
auto& i : text_array) {
100result += a1z26_decrypt_map[stoi(i)];
107 if(bReturnUppercase) {
108std::transform(result.begin(), result.end(), result.begin(), ::toupper);
122std::string input =
"Hello World";
123std::string expected =
"8-5-12-12-15 23-15-18-12-4";
126std::cout <<
"Input: "<< input << std::endl;
127std::cout <<
"Expected: "<< expected << std::endl;
128std::cout <<
"Output: "<< output << std::endl;
129assert(output == expected);
130std::cout <<
"TEST PASSED";
133input =
"12-15-23-5-18-3-1-19-5";
134expected =
"lowercase";
137std::cout <<
"Input: "<< input << std::endl;
138std::cout <<
"Expected: "<< expected << std::endl;
139std::cout <<
"Output: "<< output << std::endl;
140assert(output == expected);
141std::cout <<
"TEST PASSED";
144input =
"21-16-16-5-18-3-1-19-5";
145expected =
"UPPERCASE";
148std::cout <<
"Input: "<< input << std::endl;
149std::cout <<
"Expected: "<< expected << std::endl;
150std::cout <<
"Output: "<< output << std::endl;
151assert(output == expected);
152std::cout <<
"TEST PASSED";
std::string decrypt(const std::string &text, bool bReturnUppercase=false)
a1z26 decryption implementation
std::string encrypt(std::string text)
a1z26 encryption implementation
static void test()
Self-test implementations.
int main()
Main function.
Functions for A1Z26 encryption and decryption implementation.
Algorithms for encryption and decryption.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4