Exemple #1
0
def encode(data, msg):
    if not pystegcfg.encoding in pystegcfg.encodingopts:
        raise ValueError("Encoding [{0}] is invalid. Can only be one of {1}".format(pystegcfg.encoding, pystegcfg.encodingopts))

    if pystegcfg.encoding is "base64":
        encMsg = base64.b64encode(msg) + pystegcfg.delim
    elif pystegcfg.encoding is "none":
        encMsg = msg + pystegcfg.delim

    encMask = tb.text2uint8mask(encMsg)
    if(data.size < len(encMsg)):
        raise StegoException.EncodeError("Data size [{0}] is too small to fit encoded message of size [{1}]".format(data.size, len(encMask)))

    encData = mask.applyHaar(data, encMask)

    return encData
 def test_text2mask2text(self):
     msg = tb.uint8mask2text(tb.text2uint8mask(self.plainText))
     self.assertEqual(msg, self.plainText)
 def test_text2uint8mask(self):
     maskarr = tb.text2uint8mask(self.plainText)
     numpy.testing.assert_array_equal(maskarr, self.uint8Mask)