MOD: working on writing the jpg files
This commit is contained in:
parent
79e35190a8
commit
f397467af9
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
#
|
# This Class handles the binary parsing of a jpg file
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# 0xFF,0xD8 - Start of Image (0xFFD8FF to be used as JPG file marker)
|
# 0xFF,0xD8 - Start of Image (0xFFD8FF to be used as JPG file marker)
|
||||||
|
@ -258,13 +258,3 @@ class JpgBin:
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return repr(self.jpg_fp)
|
return repr(self.jpg_fp)
|
||||||
|
|
||||||
#
|
|
||||||
def findMarkers222(self):
|
|
||||||
last_idx = len(self.data_buf)
|
|
||||||
|
|
||||||
while ord(self.data_buf[self.data_idx]) != 0xFF:
|
|
||||||
self.data_idx = self.data_idx+1
|
|
||||||
|
|
||||||
for idx in range(last_idx):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
class JpgBinWrite:
|
||||||
|
|
||||||
|
soi = 0xffd8
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def writeJpgPicSeal(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def writeJpgMetadata(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
def writeJpgImgData(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
#
|
# This Class contains information for the jpg markers, length, an position in the file
|
||||||
#
|
#
|
||||||
class JpgFingerprint:
|
class JpgFingerprint:
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class JpgMarker:
|
||||||
self.hex = mhex
|
self.hex = mhex
|
||||||
self.hexstr = self.hex.to_bytes(2, 'big').hex()
|
self.hexstr = self.hex.to_bytes(2, 'big').hex()
|
||||||
self.fpos = fpos
|
self.fpos = fpos
|
||||||
self.len = mlen
|
self.len = mlen
|
||||||
self.type = mstr
|
self.type = mstr
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,18 +8,15 @@
|
||||||
class JpgPicSeal:
|
class JpgPicSeal:
|
||||||
|
|
||||||
def __init_(self):
|
def __init_(self):
|
||||||
self.pubkey = None
|
self.sig = None
|
||||||
self.pvtkey = None
|
|
||||||
self.imghash = None
|
|
||||||
self.imgsig = None
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#
|
#
|
||||||
def writePicSealJpg(self, fname):
|
def serilize(self, fname):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
def readPicSealJpg(self, fname):
|
def deserialize(self, fname):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,11 @@ from libs.jpg_bin import JpgBin
|
||||||
from libs.crypto_pub import Signature
|
from libs.crypto_pub import Signature
|
||||||
|
|
||||||
|
|
||||||
class JpgTools:
|
class JpgProc:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.fh = None
|
self.fh = None
|
||||||
|
self.fn = ""
|
||||||
self.jpg = None
|
self.jpg = None
|
||||||
self.sig = None
|
self.sig = None
|
||||||
self.is_processed = False
|
self.is_processed = False
|
||||||
|
@ -18,8 +19,9 @@ class JpgTools:
|
||||||
#
|
#
|
||||||
# process a jpg file, read only
|
# process a jpg file, read only
|
||||||
#
|
#
|
||||||
def getJpgBin(self, fname):
|
def jpgProc(self, fname):
|
||||||
self.fh = open(fname, "rb")
|
self.fh = open(fname, "rb")
|
||||||
|
self.fn = fname
|
||||||
self.jpg = JpgBin()
|
self.jpg = JpgBin()
|
||||||
retval = self.jpg.processFile(self.fh)
|
retval = self.jpg.processFile(self.fh)
|
||||||
logging.info("processFile()=={}".format(retval))
|
logging.info("processFile()=={}".format(retval))
|
||||||
|
@ -31,10 +33,18 @@ class JpgTools:
|
||||||
#
|
#
|
||||||
def jpgHash(self):
|
def jpgHash(self):
|
||||||
if (not self.is_processed):
|
if (not self.is_processed):
|
||||||
self.getJpgBin(fname)
|
return 0xdeadbeef
|
||||||
|
|
||||||
# hash the jpg image data
|
# hash the jpg image data
|
||||||
self.sig = Signature()
|
self.sig = Signature()
|
||||||
img_hash = self.jpg.genHash(self.sig.hh)
|
img_hash = self.jpg.genHash(self.sig.hh)
|
||||||
logging.info("img_hash-size=={}, img_hash=={}".format(len(img_hash), img_hash))
|
logging.info("img_hash-size=={}, img_hash=={}".format(len(img_hash), img_hash))
|
||||||
return img_hash
|
return img_hash
|
||||||
|
|
||||||
|
|
||||||
|
def writePicSealJpg(self, fname=None):
|
||||||
|
if not fname:
|
||||||
|
pass
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import logging
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
#from subprocess import Popen, PIPE, check_call
|
#from subprocess import Popen, PIPE, check_call
|
||||||
from libs.toolbox import Toolbox
|
from libs.toolbox import Toolbox
|
||||||
from libs.jpg_tools import JpgTools
|
from libs.jpg_proc import JpgProc
|
||||||
|
|
||||||
printall = False
|
printall = False
|
||||||
printmeta = False
|
printmeta = False
|
||||||
|
@ -22,8 +22,8 @@ def main():
|
||||||
# create new pub keys, sign hash
|
# create new pub keys, sign hash
|
||||||
# export signature & public key to a new image file
|
# export signature & public key to a new image file
|
||||||
def processImage(image_fn):
|
def processImage(image_fn):
|
||||||
jpg = JpgTools()
|
jpg = JpgProc()
|
||||||
jpg_bin = jpg.getJpgBin(image_fn)
|
jpg.getProc(image_fn)
|
||||||
img_hash = jpg.jpgHash()
|
img_hash = jpg.jpgHash()
|
||||||
|
|
||||||
printImageInfo(jpg_bin)
|
printImageInfo(jpg_bin)
|
||||||
|
|
Loading…
Reference in New Issue