Created
May 11, 2009 18:50
-
-
Save kishba/110103 to your computer and use it in GitHub Desktop.
Revisions
-
kishba revised this gist
May 11, 2009 . 1 changed file with 16 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,16 +8,28 @@ int main() { int base_value, encrypted_value, key; char c, encrypted_c; mystring = "This is a long string of characters -- now with more punctuation!"; key = 1; cout << "This program shifts lowercase things over a character!" << endl; for (int i=0; i<mystring.size(); i++) { c = mystring[i]; // capitalize any lowercase characters if (c >= 'a' && c <= 'z') { c = c - 32; } if (c >= 'A' && c <= 'Z') { base_value = int(c) - 65; encrypted_value = (base_value + key) % 26; encrypted_c = char(encrypted_value + 65); } else { base_value = 0; encrypted_value = 0; encrypted_c = c; } // print out the current character and ascii value cout << c << " (" << base_value << ")" << " -> "; -
kishba revised this gist
May 11, 2009 . 1 changed file with 24 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,15 +3,30 @@ using namespace std; int main() { string mystring; int base_value, encrypted_value, key; char c, encrypted_c; mystring = "stuff"; key = 1; cout << "This program shifts lowercase things over a character!" << endl; for (int i=0; i<mystring.size(); i++) { c = mystring[i]; base_value = int(c) - 97; encrypted_value = (base_value + key) % 26; encrypted_c = char(encrypted_value + 97); // print out the current character and ascii value cout << c << " (" << base_value << ")" << " -> "; // print out the new character and ascii value cout << encrypted_c << " (" << encrypted_value << ")"; cout << endl; } return 0; } -
kishba revised this gist
May 11, 2009 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,8 @@ int main() { mystring = "stuff"; for (int i=0; i<mystring.size(); i++) { cout << mystring[i] << " == " << int(mystring[i]) << " -> "; cout << (mystring[i] + 1) << " - " << char(mystring[i] + 1) << "\n"; } return 0; -
kishba revised this gist
May 11, 2009 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ int main() { mystring = "stuff"; for (int i=0; i<mystring.size(); i++) { cout << mystring[i] << "\n"; } -
kishba revised this gist
May 11, 2009 . 1 changed file with 11 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,16 @@ #include <iostream> #include <string> using namespace std; int main() { string mystring; mystring = "stuff"; for (int i=0; i<5; i++) { cout << mystring[i] << "\n"; } return 0; } -
kishba revised this gist
May 11, 2009 . 1 changed file with 6 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,13 @@ #include <iostream> using namespace std; int main() { string mystring = "stuff"; for (int i=0; i<mystring.size; i++) { cout << mystring[i] << "\n"; } return 0; } -
kishba created this gist
May 11, 2009 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ int main() { mystring = "stuff"; for (int i=0; i<mystring.size; i++) { echo mystring[i]; } return 0; }