herrDeng網內搜尋

自訂搜尋

Ads

2022年6月7日 星期二

資訊安全解出隱寫術steganography藏圖資訊


  1. print('練習隱寫術,需要opencv-python')
  2. from google.colab.patches import cv2_imshow
  3. from google.colab import files
  4. def showFile(s, imfile, sz=(635,773)):
  5. im=cv2.imread(imfile)
  6. h, w, ch=im.shape
  7. print(h, w, ch)
  8. if (w,h)!=sz:
  9. im=cv2.resize(im, sz)
  10. cv2_imshow(im)
  11. return im
  12. f=files.upload()
  13. fs=[]
  14. print('請上傳原圖與藏資訊的圖')
  15. for s in f.keys():
  16. print(s)
  17. fs.append(s)
  18. print(fs)
  19. x=showFile(fs[0], fs[0])
  20. y=showFile(fs[1],fs[1])
  21. print('解LSB steganography要先xor')
  22. z=cv2.bitwise_xor(x,y)
  23. print('*255')
  24. w=z*255
  25. cv2_imshow(w)
  26. cv2.imwrite('solve.png',w)
  27. #cv2.waitKey(0)
  28. files.download('solve.png')
  29.  

沒有留言:

Related Posts Plugin for WordPress, Blogger...

熱門文章