gpt4 book ai didi

Issues in Decryption(解密中的几个问题)

转载 作者:bug小助手 更新时间:2023-10-27 19:47:59 32 4
gpt4 key购买 nike



The input image is grayscale image broken down to 64 pixels block .The encryption function takes 64 pixels(512 bits) as input_value and 64 bit key. We split the input_value to blocks of 8 pixels value. We do 16 rounds of encryption on a set of 8 pixels . Every other function does some computation and return the value in a similar format.

输入图像是被分解为64像素块的灰度图像,加密函数采用64像素(512位)作为输入值和64位密钥。我们将INPUT_VALUE分成8个像素值的块。我们对一组8个像素进行16轮加密。其他每个函数都进行一些计算,并以类似的格式返回值。


When xor_8_pixels function was not used in for loop the code executed correctly for both encryption and decryption. On adding the xor_8_pixels function the decryption did not return back the original input image.(Most probably I've not positioned xor function in decryption correctly)

当在for循环中未使用xor_8_Pixels函数时,代码将正确执行加密和解密。在添加XOR_8_Pixels函数时,解密没有返回原始输入图像。(很可能我在解密中没有正确定位XOR函数)


def encryption(input_value, key_value):
keyList = create_key_list(key_value)
result = []
input_blocks = []
for i in range(8):
sub_block = (input_value[8*i:8*i+8])
input_blocks.append(sub_block)
# print(input_blocks)
for i in range(16): #16 rounds
for j in range(8):
if j < 7:
input_blocks[j] = xor_8_pixels(input_blocks[j], input_blocks[j - 1])
input_blocks[j]=OwnFunctionEncrypt(input_blocks[j], keyList[i][j])

if i < 15:
input_blocks = left_shift(input_blocks)
# print(input_blocks)
for i in range(8):
for j in range(8):
result.append(input_blocks[i][j])
return result

def decryption(input_value, key_value):
keyList = create_key_list(key_value)
result = []
input_blocks = []
for i in range(8):
sub_block = (input_value[8*i:8*i+8])
input_blocks.append(sub_block)
# print(input_blocks)
for i in range(16): # 16 rounds
for j in range(8):
if j < 7:
input_blocks[j + 1] = xor_8_pixels(input_blocks[j], input_blocks[j + 1])
input_blocks[j] = OwnFunctionDecrypt(input_blocks[j], keyList[15 - i][j]) # Decrypt
# XOR with the next block
if i < 15:
input_blocks = right_shift(input_blocks)
# print(input_blocks)
for i in range(8):
for j in range(8):
result.append(input_blocks[i][j])
return result

更多回答

you should probably include the xor_8_pixels function and anything else needed to make this a minimal reproducible example.

您可能应该包含xor_8_Pixels函数以及使其成为最小可重现性示例所需的任何其他内容。

优秀答案推荐

Even without seeing your code, is likely you're putting one of the XOR's in the wrong place. You want to do your encryption in "CBC mode".

即使没有看到您的代码,您也可能将其中一个XOR放在了错误的位置。你想在“CBC模式”下进行加密。



  • In encryption, you take the most recent block of output and xor with
    the next block of input before encrypting it

    在加密中,在加密之前,您将最近的输出块与下一个输入块进行异或运算



  • In decryption, you take take the most previous ciphertext and xor it
    with the results of the current decryption.

    在解密过程中,您获取最前面的密文,并将其与当前解密的结果进行异或运算。




Note that these are not symmetric. The pictures on the Wikipedia page should make it clearer.

请注意,这些不是对称的。维基百科页面上的图片应该会让它更清晰。


更多回答

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com