def decode(data): if not pystegcfg.encoding in pystegcfg.encodingopts: raise ValueError("Encoding [{0}] is invalid. Can only be one of {1}".format(pystegcfg.encoding, pystegcfg.encodingopts)) encMask = mask.extractHaar(data) encMsg = tb.uint8mask2text(encMask) # Extract all instances of the encoded message from the encMsg string encMsgList = encMsg.split(pystegcfg.delim) # remove any empty array elements encMsgList = filter(None, encMsgList) encMsgListCounted = collections.Counter(encMsgList).most_common() nElem = len(encMsgListCounted) if(nElem < 1): raise StegoException.DecodeError("No message to decode") return encMsgListCounted
def test_text2mask2text(self): msg = tb.uint8mask2text(tb.text2uint8mask(self.plainText)) self.assertEqual(msg, self.plainText)
def test_uint8mask2text(self): msg = tb.uint8mask2text(self.uint8Mask) self.assertEqual(msg, self.plainText)