All SolutionsAll Solutions
🖼️
Steganographia
Week 9, 2026
Python Pygame Method | Alexevi | Python Solutions
import pygame
pygame.init()
image = pygame.image.load("message.png")
msg = ""
for y in range(image.get_height()):
for x in range(image.get_width()):
color = image.get_at((x, y))
msg = msg + chr(color.r) + chr(color.g) + chr(color.b)
print(msg)
Python - Pillow Library | BMC | Python Solutions
from PIL import Image
def Decode(imgP):
img = Image.open(imgP).convert("RGB")
pixels = list(img.getdata())
message = ""
for r, g, b in pixels:
message += chr(r) + chr(g) + chr(b)
return message
file = open("ans.txt", 'w')
file.write(Decode("message.png"))
file.close()
Load image, adjust pixel format, use as cstring | greenya | Odin Solutions
package main
import "core:fmt"
import "core:strings"
import rl "vendor:raylib"
message_png_bytes := #load("message.png")
main :: proc () {
img := rl.LoadImageFromMemory(".png", raw_data(message_png_bytes), i32(len(message_png_bytes)))
rl.ImageFormat(&img, .UNCOMPRESSED_R8G8B8)
defer rl.UnloadImage(img)
bytes_per_pixel :: 3 // bytes per pixel for UNCOMPRESSED_R8G8B8 is 3
bytes_count := bytes_per_pixel * int(img.width) * int(img.height)
message := strings.string_from_null_terminated_ptr(cast ([^]u8) img.data, bytes_count)
fmt.println("-------- message { --------")
fmt.println(message)
fmt.println("-------- } message --------")
}
extract the RGB values - convert to binary | Draw6 | C++ Solutions
#include <iostream>
#include <fstream>
#include <bitset>
#include <string>
#include <vector>
using namespace std;
// get RGB values from another utility I had to write, using stb_image.h from:
// https://github.com/nothings/stb/blob/master/stb_image.h
std::string rgbToBinary(int r, int g, int b) // convert RGB to binary<8>bits
{
if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255)
{
return "Invalid RGB value";
}
cout << std::bitset<8>(r).to_string();
return std::bitset<8>(r).to_string();
}
int main()
{
string fline, conv = "";
string convR,convG,convB = "";
int iR,iG,iB = 0;
vector<string> vred;
vector<string> vgreen;
vector<string> vblue;
fstream outputfile;//"linked" is the filename of output from that other utility
outputfile.open("linked", ios::out | ios::in | ios::app);
if (!outputfile.is_open())
{
cout << "Error: Unable to open \"linked\"!\n";
return false;
}
else
{
while(getline(outputfile, fline))
{
convR = fline;
vred.push_back(convR);
convG = fline;
vgreen.push_back(convG);
convB = fline;
vblue.push_back(convB);
}
for(int i = 0; i < vred.size(); i++)
{ //uses vector's index
iR = stoi(vred[i]);
iG = stoi(vgreen[i]);
iB = stoi(vblue[i]);
conv = rgbToBinary(iR, iG, iB);// just to run function
}
}
return 0;
}
//EOF