Created
December 29, 2022 23:29
-
-
Save sean3z/0918fd2f329820e2b3e10f88b5bc234a to your computer and use it in GitHub Desktop.
WOL Apgar routine in CPP (RenegadeProjects.com)
This file contains 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 characters
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