Skip to content

Commit

Permalink
Fix bug where some letters don't appear encrypted/decrypted with cert…
Browse files Browse the repository at this point in the history
…ain keys.
  • Loading branch information
winexe0 committed Dec 13, 2022
1 parent 97107dd commit 578aa95
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/decrypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ int decrypt() {
if (newPosition < 0) {
newPosition = newPosition + alphabet.size();
}
if (newPosition == 26) {
newPosition = 0;
}
int newCharacter = alphabet[newPosition];
newMessage += newCharacter;
}
Expand All @@ -56,6 +59,9 @@ int decrypt() {
if (newPosition < 0) {
newPosition = newPosition + ualphabet.size();
}
if (newPosition == 26) {
newPosition = 0;
}
int newCharacter = ualphabet[newPosition];
newMessage += newCharacter;
}
Expand Down Expand Up @@ -115,6 +121,9 @@ int decrypt() {
if (newPosition < 0) {
newPosition = alphabet.size() + newPosition;
}
if (newPosition == 26) {
newPosition = 0;
}
int newCharacter = alphabet[newPosition];
newMessage += newCharacter;
}
Expand All @@ -124,6 +133,9 @@ int decrypt() {
if (newPosition < 0) {
newPosition = ualphabet.size() + newPosition;
}
if (newPosition == 26) {
newPosition = 0;
}
int newCharacter = ualphabet[newPosition];
newMessage += newCharacter;
}
Expand Down
12 changes: 12 additions & 0 deletions src/encrypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ int encrypt() {
if (newPosition > alphabet.size()) {
newPosition = newPosition - alphabet.size();
}
if (newPosition == 26) {
newPosition = 0;
}
int newCharacter = alphabet[newPosition];
newMessage += newCharacter;
}
Expand All @@ -56,6 +59,9 @@ int encrypt() {
if (newPosition > ualphabet.size()) {
newPosition = newPosition - ualphabet.size();
}
if (newPosition == 26) {
newPosition = 0;
}
int newCharacter = ualphabet[newPosition];
newMessage += newCharacter;
}
Expand Down Expand Up @@ -115,6 +121,9 @@ int encrypt() {
if (newPosition > alphabet.size()) {
newPosition = newPosition - alphabet.size();
}
if (newPosition == 26) {
newPosition = 0;
}
int newCharacter = alphabet[newPosition];
newMessage += newCharacter;
}
Expand All @@ -124,6 +133,9 @@ int encrypt() {
if (newPosition > ualphabet.size()) {
newPosition = newPosition - ualphabet.size();
}
if (newPosition == 26) {
newPosition = 0;
}
int newCharacter = ualphabet[newPosition];
newMessage += newCharacter;
}
Expand Down

0 comments on commit 578aa95

Please sign in to comment.