Score:2

How to use Pygame to do crib dragging

ps flag

I have two files ctext0 and ctext1 that are byte files and they are encoded using the same one time pad, so I tried to write a pygame program to allow me to use crib-dragging to figure out some words like so:

import pygame
import sys
import os

file_size1 = os.path.getsize('ctext0')
file_size2 = os.path.getsize('ctext1')

pygame.init()

# Load the byte files
with open('ctext0', 'rb') as f0:
    ctext0 = f0.read()

with open('ctext1', 'rb') as f1:
    ctext1 = f1.read()

# Create the window
window = pygame.display.set_mode((800, 600))


# Main loop
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()

    # Draw the byte files
    image0 = pygame.image.frombuffer(ctext0, (file_size1 // 3, file_size1 // 3), 'RGB', False)
    image1 = pygame.image.frombuffer(ctext1, (file_size2 // 3, file_size2 // 3), 'RGB', False)
    window.blit(image0, (0, 0))
    window.blit(image1, (100, 0))

    # Update the display
    pygame.display.update()

However this program just opens a black screen and immediately exits the program. With the following printed to the terminal: pygame 2.5.0 (SDL 2.28.0, Python 3.11.3) Hello from the pygame community. https://www.pygame.org/contribute.html

Maarten Bodewes avatar
in flag
Normally I would have migrated this question to SO, but due to the moderator strike we were not able to (see side bar / meta). If you want I can still migrate, but please let me know if this is still required after so long.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.