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)
def encode(data, msg, tiling): 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.applyLSB(data, encMask, tiling) return encData
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)