コード例 #1
0
 def sliderReleased(self):
     img = S.imageToArray(self.P1fname)
     payload = S.Payload(
         rawData=img,
         compressionLevel=self.slideCompression.sliderPosition())
     self.txtPayloadSize.setText(str(len(payload.json)))
     self.checkEmbedEnabled()
コード例 #2
0
ファイル: TariqClient.py プロジェクト: P2ppyJack/tariq
def gen_payload(img_fn, s):
  """
  put text s into image file img_fn x
  and return the modified image file content
  """
  in_file=StringIO.StringIO(s)
  out_file=StringIO.StringIO()
  # for example in 16-bit they use 565 for rgb see http://en.wikipedia.org/wiki/Color_depth
  # because human eye is more sensitive to the color green
  Steganography.encode(img_fn, in_file, red_bits=1, green_bits=1, blue_bits=1).save(out_file,format='png')
  return out_file.getvalue()
コード例 #3
0
    def embed(self):

        aa = Steganography.Carrier(self.carrier_array)
        bb = Steganography.Payload(self.payload_array,compressionLevel=self.compression)
        final_img = aa.embedPayload(bb,override=True)


        filePath, _ = QFileDialog.getSaveFileName(self, caption='Save Image ...', filter="PNG files (*.png)")

        if not filePath:
            return

        scipy.misc.imsave(filePath+'.png',final_img)
コード例 #4
0
 def compressionChecked(self):
     if self.chkApplyCompression.isChecked():
         self.lblLevel.setEnabled(True)
         self.slideCompression.setEnabled(True)
         self.txtCompression.setEnabled(True)
         self.sliderReleased()
     else:
         self.lblLevel.setEnabled(False)
         self.slideCompression.setEnabled(False)
         self.txtCompression.setEnabled(False)
         img = S.imageToArray(self.P1fname)
         payload = S.Payload(rawData=img)
         self.txtPayloadSize.setText(str(len(payload.json)))
     self.checkEmbedEnabled()
コード例 #5
0
def gen_payload(img_fn, s):
    """
  put text s into image file img_fn x
  and return the modified image file content
  """
    in_file = StringIO.StringIO(s)
    out_file = StringIO.StringIO()
    # for example in 16-bit they use 565 for rgb see http://en.wikipedia.org/wiki/Color_depth
    # because human eye is more sensitive to the color green
    Steganography.encode(img_fn,
                         in_file,
                         red_bits=1,
                         green_bits=1,
                         blue_bits=1).save(out_file, format='png')
    return out_file.getvalue()
コード例 #6
0
    def updateCompressionTextBox(self):
        self.payload1 = Steganography.Payload(
            img=self.pay1Img, compressionLevel=self.compressionLevelVal)
        self.payloadSizeVal = len(self.payload1.content)
        self.txtPayloadSize.setText(str(self.payloadSizeVal))

        self.checkSaveBtnConds()
コード例 #7
0
def decrypt(filename, password, magic, rsa):
    '''
    A method that decrypt text from image

    Args:
	filename (str) : The filename of the image
  	password (str) : Used to decrypt text
	magic    (str) : Used to retrieve text from image

    Returns:
	Text hided in image
    '''

    try:
        image = ImageHandler(filename)
        # Load image
        data = image.load_image()

        # Retrieve text
        text = Steganography.retrieve_lsb(data, magic)

        # Optional Decrypt
        if not password is None:
            print '[*] Decrypting text'
            text = Encryption.decrypt_text(password, text)
        if not rsa is None:
            print '[*] Decrypting text'
            text = Encryption.decrypt_rsa(text, rsa)

        print '[*] Retrieved text: \n%s' % text
    except Exception, e:
        print str(e)
コード例 #8
0
    def newCarrier1(self):
        print("Carrier1")
        self.carrier1InPlace = True

        self.car1Img = self.viewCarrier1.imgArr
        self.carrier1 = Steganography.Carrier(img=self.car1Img)

        self.existsPayload = self.carrier1.payloadExists()

        if self.existsPayload:
            self.chkOverride.setEnabled(True)
            self.lblPayloadFound.setText(">>>> Payload Found <<<<")
        else:
            self.chkOverride.setEnabled(False)
            self.lblPayloadFound.setText("")

        if len(self.carrier1.img.shape) == 3:
            self.carrierSizeVal = self.carrier1.img.shape[
                0] * self.carrier1.img.shape[1]
        else:
            self.carrierSizeVal = self.carrier1.img.size

        self.txtCarrierSize.setText(str(self.carrierSizeVal))

        self.checkSaveBtnConds()
コード例 #9
0
ファイル: main.py プロジェクト: Alfatoxin/alfatoxin.github.io
def encodeImage():
    filename = "imageA.jpg"
    data = open("image_original/" + filename, 'rb').read().hex()
    datalist = {"name": filename, "data": data}
    data = json.dumps(datalist)

    img = "image_original/imageB.jpg"
    image = Steganography.Image.open(img, 'r')
    if (len(data) == 0):
        raise ValueError('Data is empty')

    newimg = image.copy()
    Steganography.encode_enc(newimg, data)

    new_img_name = "image_encode/imageinimage.png"
    newimg.save(new_img_name, str(new_img_name.split(".")[1].upper()))
コード例 #10
0
 def viewCarrier2DropEvent(self, event):
     if event.mimeData().hasUrls:
         event.setDropAction(Qt.CopyAction)
         for url in event.mimeData().urls():
             fname = str(url.toLocalFile())
         if fname and fname.endswith(".png"):
             self.C2fname = fname
             try:
                 self.carrier2 = S.Carrier(S.imageToArray(self.C2fname))
                 self.viewCarrier2lLoadImage()
                 self.viewPayload2.setScene(QGraphicsScene())
                 self.setCarrier2Widgets(self.carrier2)
             except ValueError:
                 event.ignore()
         else:
             event.ignore()
コード例 #11
0
 def newImage(self):
     try:
         payload = Steganography.Payload(self.viewPayload1.imageArray,
                                         self.compression, None)
         self.txtPayloadSize.setText("{0}".format(len(payload.xml)))
     except ValueError:
         self.txtPayloadSize.setText("0")
コード例 #12
0
    def extract(self):

        a = Steganography.Carrier(self.carrier2_array)
        b = a.extractPayload()
        filePath = "/home/yara/ee364/ee364b02/Lab11/new.png"
        scipy.misc.imsave(filePath,b.img)
        self.displayImage(self.viewPayload2,filePath)
コード例 #13
0
ファイル: main.py プロジェクト: DeWill404/Steganography
def retrieve():
    msgR = ""
    passwdR = ""
    inputImgR = ""
    inputImgR = printIImgR["text"]
    if passwordStateR.get():
        passwdR = passwordEntryR.get()
    if (passwordStateR.get() and (passwdR == "")) or (inputImgR == ""):
        messagebox.showerror("Error", "Incomplete information....")
    else:
        sn = Steganography.Steg()
        try:
            msgR = sn.retr(inputImgR)
            if passwordStateR.get():
                en = Encryption.Encrypt(msgR, passwdR)
                msgR = en.decryptMessage()
            if (msgR == "!-)=~"):
                messagebox.showarning("Warning",
                                      "Incorrect password or image....")
            else:
                messageEntryR.delete('1.0', END)
                messageEntryR.insert(tk.END, msgR)
                messagebox.showinfo("Successfull",
                                    "Information is retrieved....")
        except:
            messagebox.showerror("Error", "Incorrect password or image....")
        resetR()
コード例 #14
0
ファイル: main.py プロジェクト: DeWill404/Steganography
def hide():
    msg = ""
    passwd = ""
    inputImg = ""
    outputDir = ""
    msg = messageEntry.get('1.0', END)
    msg = msg[:-1]
    if passwordState.get():
        passwd = passwordEntry.get()
    inputImg = printIImg["text"]
    outputDir = printOImg["text"]
    if (msg == "") or (passwordState.get() and
                       (passwd == "")) or (inputImg == "") or (outputDir
                                                               == ""):
        messagebox.showerror("Error", "Incomplete information....")
        textMsgRadio.invoke()
    else:
        if passwordState.get():
            en = Encryption.Encrypt(msg, passwd)
            msg = en.encryptMessage()
            print(msg)
        sn = Steganography.Steg()
        sn.hide(inputImg, outputDir, msg)
        messagebox.showinfo("Successfull", "Information is hidden....")
        resetH()
コード例 #15
0
    def compression_1(self):

        if self.chkApplyCompression.isChecked():
            self.slideCompression.setEnabled(True)
            self.compression = self.slideCompression.value()
            if self.flag == 1:
                self.set_diplays(self.viewPayload1, self.filePath_pay)

                if self.flag_carrier == 1 and self.flag_payload == 1:
                    aa = Steganography.Carrier(self.carrier_array)
                    if aa.payloadExists() and self.chkOverride.isChecked() and (self.size_carrier > self.size_payload):
                        self.btnSave.setEnabled(True)

                    elif (not(aa.payloadExists())) and (self.size_carrier > self.size_payload):
                        self.btnSave.setEnabled(True)

                    else:
                        self.btnSave.setEnabled(False)









            self.slideCompression.valueChanged.connect(lambda: self.set_value_compression() )


        else:
            self.slideCompression.setEnabled(False)
            self.compression = -1
            if self.flag == 1:
                self.set_diplays(self.viewPayload1, self.filePath_pay)

                if self.flag_carrier == 1 and self.flag_payload == 1:
                    aa = Steganography.Carrier(self.carrier_array)
                    if aa.payloadExists() and self.chkOverride.isChecked() and (self.size_carrier > self.size_payload):
                        self.btnSave.setEnabled(True)

                    elif (not(aa.payloadExists())) and (self.size_carrier > self.size_payload):
                        self.btnSave.setEnabled(True)

                    else:
                        self.btnSave.setEnabled(False)
コード例 #16
0
    def clean(self):

        a = Steganography.Carrier(self.carrier2_array)
        b = a.clean()

        scipy.misc.imsave(self.filePath,b)
        self.lblCarrierEmpty.setText(">>>>Carrier Empty<<<<")
        self.btnExtract.setEnabled(False)
        self.btnClean.setEnabled(False)
コード例 #17
0
    def random(self):
       if self.flag_carrier == 1 and self.flag_payload == 1:


            aa = Steganography.Carrier(self.carrier_array)
            if aa.payloadExists() and self.chkOverride.isChecked() and (self.size_carrier > self.size_payload):
                self.btnSave.setEnabled(True)
            elif (not(aa.payloadExists())) and (self.size_carrier > self.size_payload):
                self.btnSave.setEnabled(True)
            else:
                self.btnSave.setEnabled(False)
コード例 #18
0
 def newpayload(self):
     self.pay_img = self.viewPayload1.imgArr
     self.payload = Steganography.Payload(self.pay_img, self.compression)
     self.payloadsize = len(self.payload.xml)
     self.txtPayloadSize.setText(str(self.payloadsize))
     self.payloadsize *= 8
     if ((self.chkOverride.isChecked() or
          (self.carr and self.carr.payloadExists() == False)) and
         (self.payloadsize > 0 and self.payloadsize < self.carriersize)):
         self.btnSave.setEnabled(True)
     else:
         self.btnSave.setEnabled(False)
コード例 #19
0
 def newcarrier2(self):
     self.carr2 = Steganography.Carrier(self.viewCarrier2.imgArr)
     scn = QtGui.QGraphicsScene()
     scn.clear()
     self.viewPayload2.setScene(scn)
     self.viewPayload2.show()
     if (self.carr2.payloadExists()):
         self.btnExtract.setEnabled(True)
         self.btnClean.setEnabled(True)
     else:
         self.btnExtract.setEnabled(False)
         self.btnClean.setEnabled(False)
コード例 #20
0
 def clean(self):
     cleanData = self.carrier2.clean()
     h, w, d = cleanData.shape
     img = QImage(cleanData, w, h, w * d, QImage.Format_ARGB32)
     pixmap = QPixmap(img).scaled(self.viewCarrier2.maximumViewportSize(),
                                  Qt.KeepAspectRatio)
     scene = QGraphicsScene()
     scene.addPixmap(pixmap)
     scene.update()
     self.viewCarrier2.setScene(scene)
     self.viewPayload2.setScene(QGraphicsScene())
     self.setCarrier2Widgets(S.Carrier(cleanData))
コード例 #21
0
 def updatecompress(self):
     self.txtCompression.setText(str(self.slideCompression.value()))
     if self.compression > -1:
         self.compression = self.slideCompression.value()
     self.payload = Steganography.Payload(self.pay_img, self.compression)
     self.payloadsize = len(self.payload.xml)
     self.txtPayloadSize.setText(str(self.payloadsize))
     self.payloadsize *= 8
     if ((self.chkOverride.isChecked() or
          (self.carr and self.carr.payloadExists() == False)) and
         (self.payloadsize > 0 and self.payloadsize < self.carriersize)):
         self.btnSave.setEnabled(True)
     else:
         self.btnSave.setEnabled(False)
コード例 #22
0
 def viewCarrier1DropEvent(self, event):
     if event.mimeData().hasUrls:
         event.setDropAction(Qt.CopyAction)
         for url in event.mimeData().urls():
             fname = str(url.toLocalFile())
         if fname and fname.endswith(".png"):
             self.C1fname = fname
             try:
                 img = S.imageToArray(self.C1fname)
                 self.carrier1 = S.Carrier(img)
                 self.txtCarrierSize.setText(str(img.size))
                 self.viewCarrier1lLoadImage()
                 self.chkOverride.setEnabled(False)
                 self.chkOverride.setChecked(Qt.Unchecked)
                 self.lblPayloadFound.setText("")
                 if self.carrier1.payloadExists():
                     self.lblPayloadFound.setText(">>>>Payload Found<<<<")
                     self.chkOverride.setEnabled(True)
                 self.checkEmbedEnabled()
             except ValueError:
                 event.ignore()
         else:
             event.ignore()
コード例 #23
0
def encrypt(filename, text, password, magic, rsa):
    '''
    A method that hide text into image

    Args:
        filename (str) : The filename of the image
        text     (str) : Text or text file need to be hide in image
        password (str) : Used to encrypt text
        magic    (str) : Used to hide text in image

    Returns:
        A image named new + filename, which with encrypted text in it
    '''
    # Check for file!
    text = TextHandler(text).text

    # Optional encrypt
    if not password is None:
        print '[*] Encrypting text'
        text = Encryption.encrypt_text(password, text)

    if not rsa is None:
        print '[*] Encrypting text'
        if rsa == 'new':
            new_key = Encryption.gen_key()
            Encryption.save_key(new_key, 'private_key.pem')

            text = check_rsa_key(text, 'private_key.pem')
            # text = Encryption.encrypt_rsa(text, 'private_key.pem')
        else:
            text = check_rsa_key(text, rsa)
            # text = Encryption.encrypt_rsa(text, rsa)

    if rsa is None:
        text = text_ascii(text) + ENDBIT

    try:
        image = ImageHandler(filename)

        # Load Image
        d_old = image.load_image()

        # Check if image can contain the data
        check_space(text, d_old)

        # get new data and save to image
        d_new = Steganography.hide_lsb(d_old, magic, text)
        image.save_image(d_new, 'new_' + filename)
    except Exception, e:
        print str(e)
コード例 #24
0
 def viewPayload1DropEvent(self, event):
     if event.mimeData().hasUrls:
         event.setDropAction(Qt.CopyAction)
         for url in event.mimeData().urls():
             fname = str(url.toLocalFile())
         if fname and fname.endswith(".png"):
             self.P1fname = fname
             try:
                 img = S.imageToArray(self.P1fname)
                 self.payload1 = S.Payload(rawData=img)
                 size = len(self.payload1.json)
                 self.viewPayload1LoadImage()
                 self.txtPayloadSize.setText(str(size))
                 self.chkApplyCompression.setCheckState(Qt.Unchecked)
                 self.lblLevel.setEnabled(False)
                 self.slideCompression.setEnabled(False)
                 self.txtCompression.setEnabled(False)
                 self.slideCompression.setValue(0)
                 self.txtCompression.setText('0')
                 self.checkEmbedEnabled()
             except ValueError:
                 event.ignore()
         else:
             event.ignore()
コード例 #25
0
 def newcarrier(self):
     self.carr = Steganography.Carrier(self.viewCarrier1.imgArr)
     self.carriersize = self.viewCarrier1.imgArr.size
     self.txtCarrierSize.setText(str(int(self.viewCarrier1.imgArr.size /
                                         8)))
     self.chkOverride.setEnabled(True)
     if (self.carr.payloadExists()):
         self.lblPayloadFound.setText(">>>> Payload Found<<<<")
     else:
         self.lblPayloadFound.setText("")
     if ((self.chkOverride.isChecked() or
          (self.carr.payloadExists() == False)) and
         (self.payloadsize > 0 and self.payloadsize < self.carriersize)):
         self.btnSave.setEnabled(True)
     else:
         self.btnSave.setEnabled(False)
コード例 #26
0
 def extract(self):
     payload = self.carrier2.extractPayload()
     if S.getRawDataType(payload.rawData) == 'color':
         height, width, depth = payload.rawData.shape
         img = QImage(payload.rawData, width, height, width * depth,
                      QImage.Format_RGB888)
     else:
         rgbData = self.grayToRgb(payload.rawData)
         height, width, depth = rgbData.shape
         img = QImage(rgbData, width, height, width * depth,
                      QImage.Format_RGB888)
     pixmap = QPixmap(img)
     pixmap = pixmap.scaled(self.viewPayload2.maximumViewportSize(),
                            Qt.KeepAspectRatio)
     scene = QGraphicsScene()
     scene.addPixmap(pixmap)
     scene.update()
     self.viewPayload2.setScene(scene)
コード例 #27
0
ファイル: TariqServer.py プロジェクト: P2ppyJack/tariq
 def make_reply(self, req):
     pk=IP(str(req.payload))
     tcp=pk.payload
     if tcp.flags!=4 and tcp.flags!=2: return None
     d=str(tcp.payload)
     dp=int(tcp.dport)
     s=str(pk.src)
     if tcp.flags==4:
         if dp!=self._ports[-1] or not self._challenge.has_key(s): return None
         if d.replace('\0',' ').strip()=='': return None
         print ("** Got challenge answer=[%s]") % d.__repr__()
         c,cmd,arg=self._challenge[s]
         if c==d:
             print ("** accepted, executing cmd=[%s] arg=[%s]") % (cmd,arg)
             self._q.put((s, cmd, arg))
         else: print ("rejected")
         del self._challenge[s]
         return None
     print ("dp=",dp,)
     #print "pk=", pk.__repr__()
     r=self._is_right_knock(s, dp)
     print ("** right order=", r)
     if not r: return None
     self._hist[s].append(d)
     if len(self._hist[s])==self._portsN:
         # send challenge
         img="".join(self._hist[s])
         del self._hist[s];
         in_file=StringIO.StringIO(img)
         try: d=Steganography.decode(in_file, red_bits=1, green_bits=1, blue_bits=1)
         except: return None
         try: email,cmd,arg=d.split(' ',2)
         except ValueError: return None
         print ("** last valid knock received, cmd=[%s] arg=[%s]") % (cmd, arg)
         print ("** sending challenge ...")
         dec_blob=randomblob(self._blobm,self._blobM)
         enc_blob=enc(self._gpg, dec_blob, email=email)
         print ("** expecting answer=[%s]") % dec_blob.__repr__()
         try: self._challenge[s]=(dec_blob, cmd, arg)
         except KeyError: return None
         return IP(dst=pk.src,src=pk.dst)/TCP(flags='SA',dport=tcp.sport, sport=tcp.dport, seq=tcp.seq)/enc_blob
     return None
コード例 #28
0
    def processDrop(self, view, e):
        """
        Process a drop event when it occurs on the views.
        """
        mime = e.mimeData()

        # Guard against types of drops that are not pertinent to this app.
        if not mime.hasUrls():
            return

        # Obtain the file path using the OS format.
        filePath = mime.urls()[0].toLocalFile()
        _, ext = splitext(filePath)

        if not ext == ".png":
            return

        # Now the file path is ready to be processed.
        #
        # TODO: Remove the print statement and continue the implementation using the filePath.
        #

        self.filePath = filePath
        if view == self.viewPayload1:
            self.filePath_pay = filePath
            self.flag = 0
        self.set_diplays(view,filePath)


        if self.flag_carrier == 1 and self.flag_payload == 1:


            aa = Steganography.Carrier(self.carrier_array)
            if aa.payloadExists() and self.chkOverride.isChecked() and (self.size_carrier > self.size_payload):
                self.btnSave.setEnabled(True)

            elif (not(aa.payloadExists())) and (self.size_carrier > self.size_payload):
                self.btnSave.setEnabled(True)

            else:
                self.btnSave.setEnabled(False)
コード例 #29
0
    def set_value_compression(self):

        self.compression = self.slideCompression.value()
        if self.flag == 1:
            self.set_diplays(self.viewPayload1, self.filePath_pay)

            if self.flag_carrier == 1 and self.flag_payload == 1:


                aa = Steganography.Carrier(self.carrier_array)
                if aa.payloadExists() and self.chkOverride.isChecked() and (self.size_carrier > self.size_payload):
                    self.btnSave.setEnabled(True)

                elif (not(aa.payloadExists())) and (self.size_carrier > self.size_payload):
                    self.btnSave.setEnabled(True)

                else:
                    self.btnSave.setEnabled(False)

        a = str(self.compression)
        self.txtCompression.setText(a)
コード例 #30
0
    def newCarrier2(self):
        print("Carrier2")
        self.carrier2InPlace = True

        scene = QtGui.QGraphicsScene()
        scene.clear()
        self.viewPayload2.setScene(scene)
        self.viewPayload2.show()

        self.car2Img = self.viewCarrier2.imgArr
        self.carrier2 = Steganography.Carrier(img=self.car2Img)

        self.existsPayload2 = self.carrier2.payloadExists()

        if self.existsPayload2:
            self.btnExtract.setEnabled(True)
            self.btnClean.setEnabled(True)
            self.lblCarrierEmpty.setText("")
        else:
            self.btnExtract.setEnabled(False)
            self.btnClean.setEnabled(False)
            self.lblCarrierEmpty.setText(">>>> Carrier Empty <<<<")
コード例 #31
0
        fileName = raw_input('Would You Kindly Give the Name of The File:')
        audioName = raw_input('Would You Kindly Give the Name of the Audio File:')

        strOut = ""
        f = open(audioName, "rb")
        try:
            byte = f.read(1)
            while byte != "":
                strOut = strOut + byte
                byte = f.read(1)
        finally:
            f.close()

        numBytes = len(strOut)

        Steganography.steg(Helpers.stringToBitArray(strOut), False, fileName)

    elif mode == "desteg":

        fileName = raw_input('Would You Kindly Give the Name of the File:')

        strOut = ""
        f = open("mario.mid", "rb")
        try:
            byte = f.read(1)
            while byte != "":
                strOut = strOut + byte
                byte = f.read(1)
        finally:
            f.close()
コード例 #32
0
ファイル: test.py プロジェクト: wang1540/ece364
    # sourcePath = '/home/ecegrid/a/ee364b09/Lab11/t&h/IMG_2648.png'
    # message = Message(filePath=sourcePath, messageType='ColorImage')
    # imagePath = '/home/ecegrid/a/ee364b09/Lab11/t&h/IMG_2645.png'
    # stegan = Steganography(imagePath, 'horizontal')
    # stegan.embedMessageInMedium(message, '/home/ecegrid/a/ee364b09/Lab11/t&h/tan_hui_h.png')

    # sourcePath = '/home/ecegrid/a/ee364b09/Lab11/t&h/IMG_2645(1).png'
    # message = Message(filePath=sourcePath, messageType='ColorImage')
    # imagePath = '/home/ecegrid/a/ee364b09/Lab11/t&h/IMG_2646.png'
    # stegan = Steganography(imagePath, 'horizontal')
    # stegan.embedMessageInMedium(message, '/home/ecegrid/a/ee364b09/Lab11/t&h/xinba_tan_h.png')

    sourcePath = '/home/ecegrid/a/ee364b09/Lab11/t&h/IMG_2645(1).png'
    message = Message(filePath=sourcePath, messageType='ColorImage')
    imagePath = '/home/ecegrid/a/ee364b09/Lab11/t&h/IMG_2649.png'
    stegan = Steganography(imagePath, 'vertical')
    stegan.embedMessageInMedium(
        message, '/home/ecegrid/a/ee364b09/Lab11/t&h/hui_tan_v.png')

    # sourcePath = '/home/ecegrid/a/ee364b09/Lab11/t&h/IMG_2649(1).png'
    # message = Message(filePath=sourcePath, messageType='ColorImage')
    # imagePath = '/home/ecegrid/a/ee364b09/Lab11/t&h/IMG_2645.png'
    # stegan = Steganography(imagePath, 'vertical')
    # stegan.embedMessageInMedium(message, '/home/ecegrid/a/ee364b09/Lab11/t&h/hui_tan_v.png')

    out = Image.open(imagePath)
    l, h = out.size
    print('{} and {}'.format(l, h))
    pix1 = list(out.getdata())
    out = Image.open(sourcePath)
    l, h = out.size
コード例 #33
0
ファイル: NewSteganograhy.py プロジェクト: bsarkar16/ECE364
        #Generating the message
        for byt in new_list:
            for bit in byt:
                sum += int(bit)*2**(7-k)
                k += 1
            new_list[i] = chr(int(sum))
            new_str += new_list[i]
            k = 0
            sum  = 0
            i += 1

            if i == 8000:
                break
        #Checking the right format of the message
        matches = re.findall("<message type=\"(.*)\" size",new_str)
        if len(matches) == 0:
            return (False,None)
        else:
            return (True, matches[0])

if __name__ == "__main__":
    pass
    nw = Steganography("test/bridge_dog_v.png","vertical")
    ges = nw.extractMessageFromMedium()

    print(ges)
    #print(mes,ges)
    #nw = NewSteganography(hello)
    #mes = hello.checkIfMessageExists()
    #print(mes)
コード例 #34
0
ファイル: decode.py プロジェクト: Sec-Projectz/Project_02
from PIL import Image
import Steganography as st
import cv2

img=cv2.imread('result/merged_image.png',1)
img=cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
hid_image=st.unmerge(img)
cv2.imwrite('result/secret_image.png',hid_image)