-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcypher.cpp
More file actions
25 lines (22 loc) · 935 Bytes
/
Copy pathcypher.cpp
File metadata and controls
25 lines (22 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <string>
#include "cypher.h"
/**
* String passed in the parameter gets its ASCII characters moved to either encrypt or decrypt its value
* Shifting the char to the next value (+1) is considered a encryption
* Shifting the chat to the previous value (-1) is considered a decryption
*
* @param inputString parameter that will be encrypted
* @param isEncription decides whether its a encryption or decryption, default true = encryption
* @return encrypted argument
*/
std::string encrypt_decrypt_input(std::string inputString, bool isEncription) {
size_t stringLength = inputString.length();
std::string encryptedString;
char tmpCharShift = ' ';
for (size_t i = 0; i < stringLength; i++) {
tmpCharShift = inputString[i];
tmpCharShift = isEncription ? tmpCharShift+1 : tmpCharShift-1;
encryptedString += tmpCharShift;
}
return encryptedString;
}