hamming.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:hamming-stego 作者: DakotaNelson 项目源码 文件源码
def syndrome(msg):
    """ passed a list of hamming(8,4)-encoded bits (integers, 1 or 0),
        returns an error syndrome for that list """

    msg = np.reshape(np.array(msg), (-1, 8)).T

    # syndrome generation matrix
    transition = np.mat('0,1,1,1,1,0,0,0;\
                         1,0,1,1,0,1,0,0;\
                         1,1,0,1,0,0,1,0;\
                         1,1,1,0,0,0,0,1')

    result = np.dot(transition, msg)

    # mod 2 the matrix multiplication
    return np.mod(result, 2)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号