下面是一段使用 Python 对图像进行简单加密的代码:
from PIL import Image
# Open the image file
with Image.open("image.jpg") as im:
# Convert the image to a 2D array of pixels
pixels = list(im.getdata())
width, height = im.size
pixels = [pixels[i * width:(i + 1) * width] for i in range(height)]
# Encrypt the pixels
for i in range(height):
for j in range(width):