내 프로그램은 속기 프로그램이므로 다른 이미지에 이미지를 삽입하고 표지 이미지에 삽입하기 전에 데이터를 암호화하려고합니다. 그러나 대부분의 암호화 모듈은 문자열을 필요로하며 정수를 전달하려고합니다.정수를 암호화 할 수 있습니까?
문자열로 변환 한 다음 암호화를 시도했지만 암호화에 특수 문자와 문자가 가득 찼으므로 삽입 할 정수로 다시 변환 할 수 없습니다.
어떻게 든 정수를 암호화 할 수 있는지 누구나 알고 계십니까? 매우 안전 할 필요는 없습니다.
for i in range(0,3):
#verify we have reached the end of our hidden file
if count >= len(Stringbits):
#convert the bits to their rgb value and appened them
for rgbValue in pixelList:
pixelnumbers1 = int(''.join(str(b) for b in rgbValue), 2)
#print pixelnumbers1
rgb_Array.append(pixelnumbers1)
pixels[x, y] = (rgb_Array[0], rgb_Array[1], rgb_Array[2])
print "Completed"
return imageObject.save(output)
그때 pixelnumbers1
를 암호화에 추가하기 위해 노력했습니다 그러나 pixels[x, y]
는 정수가 필요합니다
def write(mainimage, secret, output):
#string contains the header, data and length in binary
Stringbits = dcimage.createString(secret)
imageObject = Image.open(mainimage).convert('RGB')
imageWidth, imageHeight = imageObject.size
pixels = imageObject.load()
rgbDecimal_Array = []
rgb_Array = []
count = 0
#loop through each pixel
for x in range (imageWidth):
for y in range (imageHeight):
r,g,b = pixels[x,y]
#convert each pixel into an 8 bit representation
redPixel = list(bin(r)[2:].zfill(8))
greenPixel = list(bin(g)[2:].zfill(8))
bluePixel = list(bin(b)[2:].zfill(8))
pixelList = [redPixel, greenPixel, bluePixel]
#for each of rgb
for i in range(0,3):
#verify we have reached the end of our hidden file
if count >= len(Stringbits):
#convert the bits to their rgb value and appened them
for rgbValue in pixelList:
pixelnumbers1 = int(''.join(str(b) for b in rgbValue), 2)
#print pixelnumbers1
rgb_Array.append(pixelnumbers1)
pixels[x, y] = (rgb_Array[0], rgb_Array[1], rgb_Array[2])
print "Completed"
return imageObject.save(output)
#If we haven't rached the end of the file, store a bit
else:
pixelList[i][7] = Stringbits[count]
count+=1
pixels[x, y] = dcimage.getPixel(pixelList)
대부분의 암호화 시스템은 임의의 이진 데이터, 문자열 또는 둘 모두와 함께 작동합니다. "정수"는 하나의 시스템에서 다른 시스템으로 정수의 형식이 격렬하게 변화함에 따라 처리 할 수있는 개념이 아닙니다. 정수를 문자열로 변환하고 암호화 한 다음 구워 낼 수 있습니다. 암호화 된 데이터는 종종 원시 이진수이며, 문자열로 변환하려면 Base64 또는 이와 유사한 형식으로 인코딩해야합니다. – tadman
정수, 문자열 등은 이진 값의 해석 일뿐입니다. 하나의 유형을 암호화 할 수 있다면 모든 유형을 수행 할 수 있습니다. –
@ tadman "bake it in"이란 무엇을 의미합니까? –