Skip to content

Instantly share code, notes, and snippets.

@jokey2k
Created December 28, 2014 16:10
Show Gist options
  • Save jokey2k/ff203540a91fdd82c75b to your computer and use it in GitHub Desktop.
Save jokey2k/ff203540a91fdd82c75b to your computer and use it in GitHub Desktop.
import socket
import random
import time
from PIL import Image
UDP_IP = "151.217.40.31"
UDP_PORT = 12345
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
img = Image.open("test.png")
MESSAGE = ""
for (red, green, blue) in list(img.getdata()):
MESSAGE += chr(red) + chr(green) + chr(blue)
if len(MESSAGE) < 2048:
MESSAGE += "".join([chr(0) for i in range(2048+1-len(MESSAGE))])
sock.sendto("".join(MESSAGE), (UDP_IP, UDP_PORT))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment