資源簡介
基于LSB算法的BMP圖片隱寫,python實現,取RGB的最后一位存取信息
代碼片段和文件信息
#!/usr/bin/env?python
#coding=utf-8
“““
????Author:?????????Anemone
????Filename:???????new.py
????Last?modified:??2015-09-26?15:31
????E-mail:?????????anemone@82flex.com
“““
import?sys
import?struct
reload(sys)
sys.setdefaultencoding(“utf-8“)
def?encrypt(rawImgtestStr):
????testStr=testStr+“\0“
????img=open(rawImg‘rb‘)
????#?bfType=struct.unpack(“<2s“img.read(2))
????#?print?bfType
????#?bfSize=struct.unpack(“>I“img.read(4))
????#?print?hex(bfSize)
????
????bfHeader=img.read(14)
????bfTypebfSizebfReserved1bfReserved2bfOffBits=struct.unpack(“<2sI2Hi“bfHeader)
????print?bfTypebfSizebfOffBits
????biHeader=img.read(40)
????biSizebiWidthbiHeightbiPlanesbiBitCountbiCompressionbiSizeImagebiXPelsPerMeterbiYPelsPerMterbiClrUsedbiClrImportant\
????????????=struct.unpack(“<3I2H6I“biHeader)
????print?biSizebiWidthbiHeightbiPlanesbiBitCountbiCompressionbiSizeImagebiXPelsPerMeterbiYPelsPerMterbiClrUsedbiClrImportant
????if?biBitCount<16:
????????img.seek(4)
????count=0
????#?while?count ????????#?rgb=struct.unpack(“<3B“img.read(3))
????????#?count+=1
????#?encrypt
????count=0
????imgEn=open(‘fin.bmp‘‘wb‘)
????imgEn.write(bfHeader)
????imgEn.write(biHeader)
????sEncrypt=struct.pack(“%ds“%len(testStr)testStr)
????for?eachAlpha?in?testStr:
????????eachAlphaBins=bin(?ord(ea
- 上一篇:豆瓣和IMDB上電影的對比爬蟲
- 下一篇:用PYTHON實現的各類經典加解密算法
評論
共有 條評論