1. 程式人生 > >python base64字串加密解密DeeCamp

python base64字串加密解密DeeCamp

import base64
import matplotlib.pyplot as plt # plt 用於顯示圖片
import numpy as np
from PIL import Image

# f = open('mima.txt',"r");
# linedata = f.read()
# f.close()
linedata='MG4rZiJpImkvaixpLGwrbjRxN3MxdzN3M3s+fTl9OX4EQgdCAUkCSQxID0sJTAtQF1IRVBNWE1sZWhhcGiBnJStrImUmZSFmLGcgZixrKGoobypwKnIwdzJ0Mns/QANCOkAEQQFGAEYMSAxID0oJURVTEVURVhJYGVsYXxheGiIvZSdjJ2MmZyNnI2UvaiNoL2wraitwN3YzczJ7PGstcTR3BEwIRgBEAkkPSA1JDk0LURZVEVQTVBxaH1wZXmUgJ2AkYyZhJGEnZyJiI2ktZi1rL2sobChwPkA7ctWz8ILCv9eeJHYMQgZJA0kMSQhKCFAUUhFVEVQQWhldGF9lXtqf22HanyWeJmAkYyZiImktZy1qLWgxbNSH/K/EhtJlKHYhg+GyIHwFRgBGD0sOTQlOFVIWVRFUE1YZXRldGF/Ymtmd2GHan9uf2mAkYyBmIGcsZClkyJP7ufqJ13MSVANwNGong+6XOX8CRABHDE0OTQhRFFIRVRBUE1sZXBgh2JvfnNmd2JzbnNufJGElYyBlJmg3lC13NHXVkT9c2Y3eidiW23IVSDtuMEcARA1JDUsJTAtTFlURVxNZHl0YXN6a3Z3cm9ma2Z3YnNie2p8kYCd5KnUWdSdt0ogdafTYn5IodyhGfg9rTD91OkcNRg9NDk0LURdSEVUQVxJbGVzflt2V05jemt6b2J3cndic2pw2ejFFI3Mhc9RxPmDTtChObysYJW84RioddzNCA0YNRg9KCFEUUxZSEFQTWBlb05LQk9OV3ZvSl9+a3Jvend2YNW82djFlJZ3XSzVjylR1RxFPGzBoOGpeE3wyfzpHAEcMSwhOFU4WUhFVEFcfWteS1pTWkNCW05vdmd2a35/Ujy9nLGU+h8mUM0Y9RB5OCkcVWAhLGjBpKg5qNH8+fgFGDUYPSglNFVIXVRBUEF3XkNeT1pPXlNKU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zYnNvmyrNoB3ix+7zloqHI1aHFvuEBLzN5bjw3VHshEyxrA3eILS0afmMEGEMSFUwFey58EUsDeTBiNEk18aGaop7N49+lggt5uPy587XgkL+J8Y7ovyQeQxEyClNzLxdMbV19J/2DGjdFCQpiRhZDAnoxegxVPnYwGDRcfpOw7aKeyOGnrNMFew=='
binData = base64.standard_b64decode(linedata);

binPic = [];
i=0
while 1:
    binPic.append(binData[i])
    i +=1
    if (i>=4096):
        break
imagedata233 = np.reshape(binPic,(64,64))
image233 = Image.fromarray(imagedata233)
plt.imshow(image233)


 #print(binData[4095])
i = 0
halfData = [];
halfData2 = [];
 #找出一半的資料來
while 1:
    halfData.append(binData[i])
    halfData2.append(binData[i+1])
    i += 2
    if i>=4096:
        break
 
imagedata = np.reshape(halfData,(64,32))
image = Image.fromarray(imagedata)
plt.imshow(image)
 
imagedata = np.reshape(halfData2,(64,32))
image2 = Image.fromarray(imagedata)
plt.imshow(image2)