Skip to content

Instantly share code, notes, and snippets.

@tianhaoz95
Created February 27, 2020 04:13
Show Gist options
  • Save tianhaoz95/e5f41727d8c26accb28ab095ee123879 to your computer and use it in GitHub Desktop.
Save tianhaoz95/e5f41727d8c26accb28ab095ee123879 to your computer and use it in GitHub Desktop.
Simplified version of encoding messages into pixels
/// Steps to encode the entire byte messages into images
for (int i = 0; i < getEncoderCapacity(img); ++i) {
encodedImg[i] = encodeOnePixel(img[i], paddedMsg[i]);
}
/// Helper function to encode one bit of message into 8 pixels
int encodeOnePixel(int pixel, int msg) {
int lastBitMask = 254;
int encoded = (pixel & lastBitMask) | msg;
return encoded;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment