#include <cipher.hpp>
|
std::string | caesar (std::string plaintext, int64_t key) |
|
std::string | keyword_encode (std::string key) |
|
std::string | keyword (std::string plaintext, std::string encoded_text) |
|
- Examples
- cipher.cpp.
Definition at line 49 of file cipher.hpp.
◆ caesar()
std::string gpmp::Cipher::caesar |
( |
std::string |
plaintext, |
|
|
int64_t |
key |
|
) |
| |
- Examples
- cipher.cpp.
Definition at line 46 of file cipher.cpp.
47 std::string hashtext =
"";
49 for (int64_t i = 0; uint64_t(i) < plaintext.length(); i++) {
51 if (isupper(plaintext[i])) {
53 hashtext += char(int64_t(plaintext[i] + key - 65) % 26 + 65);
56 hashtext += char(int64_t(plaintext[i] + key - 97) % 26 + 97);
Referenced by main().
◆ keyword()
std::string gpmp::Cipher::keyword |
( |
std::string |
plaintext, |
|
|
std::string |
encoded_text |
|
) |
| |
- Examples
- cipher.cpp.
Definition at line 99 of file cipher.cpp.
101 std::string cipher =
"";
107 for (int64_t i = 0; uint64_t(i) < plaintext.size(); i++) {
108 if (plaintext[i] >=
'a' && plaintext[i] <=
'z') {
109 int64_t pos = plaintext[i] - 97;
110 cipher += encoded_text[pos];
113 else if (plaintext[i] >=
'A' && plaintext[i] <=
'Z') {
114 int64_t pos = plaintext[i] - 65;
115 cipher += encoded_text[pos];
119 cipher += plaintext[i];
Referenced by main().
◆ keyword_encode()
std::string gpmp::Cipher::keyword_encode |
( |
std::string |
key | ) |
|
- Examples
- cipher.cpp.
Definition at line 63 of file cipher.cpp.
64 std::string encoded =
"";
70 for (int64_t i = 0; uint64_t(i) < key.size(); i++) {
71 if (key[i] >=
'A' && key[i] <=
'Z') {
76 if (arr[key[i] - 65] == 0) {
80 }
else if (key[i] >=
'a' && key[i] <=
'z') {
81 if (arr[key[i] - 97] == 0) {
82 encoded += key[i] - 32;
90 for (int64_t i = 0; i < 26; i++) {
93 encoded += char(i + 65);
Referenced by main().
The documentation for this class was generated from the following files: