Exemplo n.º 1
0
 def testApplyAndExtractOnRandomNotile(self):
     data = numpy.random.randint(0, high=2, size=1000).astype(numpy.uint32)
     inputMask = numpy.random.randint(0, high=2, size=73).astype(numpy.uint8)
     encodedData = mask.applyLSB(data, inputMask, "notile")
     outputMask = mask.extractLSB(encodedData).astype(numpy.uint8)
     outputMask.resize(inputMask.size)
     numpy.testing.assert_array_equal(outputMask, inputMask)
Exemplo n.º 2
0
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.extractLSB(data)
    encMsg = tb.uint8mask2text(encMask)
    # Find the last occurrence of the delimiter
    lastPos = encMsg.rfind(pystegcfg.delim)
    if lastPos is -1:
        raise StegoException.DecodeError("Could not find any message delimiters")

    encMsg = encMsg[:lastPos]
    # 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
Exemplo n.º 3
0
 def testApplyAndExtractNotile(self):
     outputMask = mask.extractLSB(mask.applyLSB(self.data, self.mask, "notile"))
     outputMask.resize(self.mask.size)
     numpy.testing.assert_array_equal(outputMask, self.mask)