function DiffImg = DiffusionDNAImageKeyImageKeyDecimalKeyFeature m n Type Logistic Map Signal d1 = KeyDecimal1; d2 = KeyDecimal3; d3 = KeyDecimal5; d4 = KeyDecimal7; d5 = KeyDecima
def DiffusionDNA(Image, KeyImage, KeyDecimal, KeyFeature, m, n, Type): d1 = KeyDecimal[0] d2 = KeyDecimal[2] d3 = KeyDecimal[4] d4 = KeyDecimal[6] d5 = KeyDecimal[8] d6 = KeyDecimal[10] d7 = KeyDecimal[12] d8 = KeyDecimal[14] xx = (d1 ^ d2 ^ d3 ^ d4 ^ d5 ^ d6 ^ d7 ^ d8 ^ KeyFeature) / 256
u = 3.89 + xx * 0.01
Len = d1 + d2 + d3 + KeyFeature
d1 = KeyDecimal[1]
d2 = KeyDecimal[3]
d3 = KeyDecimal[5]
d4 = KeyDecimal[7]
d5 = KeyDecimal[9]
d6 = KeyDecimal[11]
d7 = KeyDecimal[13]
d8 = KeyDecimal[15]
x = (d1 ^ d2 ^ d3 ^ d4 ^ d5 ^ d6 ^ d7 ^ d8 ^ KeyFeature) / 256
for i in range(1, Len+1):
x = u * x * (1 - x)
Len4mn = 4 * n * m
ChaoticSignal = [0] * (Len4mn)
ChaoticSignal[0] = x
for i in range(1, Len4mn):
x = u * x * (1 - x)
ChaoticSignal[i] = x
OPERATION = [int(7 * i) + 1 for i in ChaoticSignal]
DiffImg = [0] * Len4mn
XOR = [[0, 1, 2, 3], [1, 0, 3, 2], [2, 3, 0, 1], [3, 2, 1, 0]]
ADD = [[1, 0, 3, 2], [0, 1, 2, 3], [3, 2, 1, 0], [2, 3, 0, 1]]
MUL = [[3, 2, 1, 0], [2, 3, 0, 1], [1, 0, 3, 2], [0, 1, 2, 3]]
XNOR = [[3, 2, 1, 0], [2, 3, 0, 1], [1, 0, 3, 2], [0, 1, 2, 3]]
SUB = [[1, 2, 3, 0], [0, 1, 2, 3], [3, 0, 1, 2], [2, 3, 0, 1]]
RShift = [[0, 1, 2, 3], [1, 2, 3, 0], [2, 3, 0, 1], [3, 0, 1, 2]]
LShift = [[0, 3, 2, 1], [1, 0, 3, 2], [2, 1, 0, 3], [3, 2, 1, 0]]
if Type == 'Encryption':
for i in range(Len4mn):
switch = OPERATION[i]
if switch == 1:
DiffImg[i] = ADD[Image[i]+1][KeyImage[i]+1]
elif switch == 2:
DiffImg[i] = SUB[Image[i]+1][KeyImage[i]+1]
elif switch == 3:
DiffImg[i] = XOR[Image[i]+1][KeyImage[i]+1]
elif switch == 4:
DiffImg[i] = XNOR[Image[i]+1][KeyImage[i]+1]
elif switch == 5:
DiffImg[i] = MUL[Image[i]+1][KeyImage[i]+1]
elif switch == 6:
DiffImg[i] = RShift[Image[i]+1][KeyImage[i]+1]
elif switch == 7:
DiffImg[i] = LShift[Image[i]+1][KeyImage[i]+1]
elif Type == 'Decryption':
for i in range(Len4mn):
switch = OPERATION[i]
if switch == 1:
DiffImg[i] = ADD[Image[i]+1][KeyImage[i]+1]
elif switch == 2:
DiffImg[i] = SUB[Image[i]+1][KeyImage[i]+1]
elif switch == 3:
DiffImg[i] = XOR[Image[i]+1][KeyImage[i]+1]
elif switch == 4:
DiffImg[i] = XNOR[Image[i]+1][KeyImage[i]+1]
elif switch == 5:
DiffImg[i] = MUL[Image[i]+1][KeyImage[i]+1]
elif switch == 6:
DiffImg[i] = LShift[Image[i]+1][KeyImage[i]+1]
elif switch == 7:
DiffImg[i] = RShift[Image[i]+1][KeyImage[i]+1]
return DiffIm
原文地址: http://www.cveoy.top/t/topic/iYM2 著作权归作者所有。请勿转载和采集!