Created
February 27, 2020 04:13
-
-
Save tianhaoz95/e5f41727d8c26accb28ab095ee123879 to your computer and use it in GitHub Desktop.
Simplified version of encoding messages into pixels
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 characters
| /// 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