Skip to content

Instantly share code, notes, and snippets.

@thewisenerd
Created October 23, 2015 09:11
Show Gist options
  • Save thewisenerd/2a8738df894ddf744291 to your computer and use it in GitHub Desktop.
Save thewisenerd/2a8738df894ddf744291 to your computer and use it in GitHub Desktop.
// caesar cipher algorithm in C
#define C_CIPHER (-28)
#define pyMod(n, M) (((n % M) + M) % M)
if (data > 64) { // if >= A
if (data < 91) { // if <= Z
data = 'A' + pyMod(((data - 'A') + cipher), 26);
} // <= Z
if (data > 96) { // if >= a
if (data < 123) { // if <= z
data = 'a' + pyMod(((data - 'a') + cipher), 26);
} // // if <= z
} // >= a
} // if >= A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment