我需要帮助拍摄图像,加密其中的文本消息,然后创建一个加密密钥来解码它。我是Python的初学者,只知道最基本的东西,还没有找到一个示例程序作为我要创建的这个程序的基础。任何例子或资源,可以帮助我学习如何做到这一点将是伟大的
我从下面列出的代码开始,但是这是如何将一个图像加密到另一个图像,并且不允许使用密钥进行解码
def encode(msgPic,original):
#Assume msgPic and original have same dimensions
#First, make all red pixels even
for pxl in getPixels(original):
#Using modulo operator to test oddness
if (getRed(pxl) % 2) == 1:
setRed(pxl, getRed(pxl) - 1)
# Second, wherever there's black in msgPic
# make odd the red in the corresponding original pixel
for x in range(0, getWidth(original)):
for y in range(0, getHeight(original)):
msgPxl = getPixel(msgPic,x,y)
origPxl = getPixel(original,x,y)
if (distance(getColor(msgPxl), black) < 100.0):
# It's a message pixel! Make the red value odd.
setRed(origPxl, getRed(origPxl)+1)
目前没有回答
相关问题 更多 >
编程相关推荐