Skip to content

Instantly share code, notes, and snippets.

@sean3z
Created December 29, 2022 23:29
Show Gist options
  • Save sean3z/0918fd2f329820e2b3e10f88b5bc234a to your computer and use it in GitHub Desktop.
Save sean3z/0918fd2f329820e2b3e10f88b5bc234a to your computer and use it in GitHub Desktop.
WOL Apgar routine in CPP (RenegadeProjects.com)
std::string apgar(std::string input) {
std::string lookup = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
std::string out = "";
int i = 0;
while (i < 8) {
unsigned char left = input[i];
unsigned char right = input[input.length() - i];
unsigned char x = left & 1 ? ((left << 1) ^ (left & 1)) & right : left ^ right;
out += lookup[x & 63];
i++;
}
return out;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment