예제 #1
0
  def extlen(self,orghash,msglen,imsg):

    hs = struct.unpack(">IIIII",orghash.decode('hex'))

    self.h0 = hs[0]
    self.h1 = hs[1]
    self.h2 = hs[2]
    self.h3 = hs[3]
    self.h4 = hs[4]

    self.mesg = imsg
    tempmsg = c28.padding(msglen)+imsg
    self.lmsg = msglen + len(tempmsg)
    return tempmsg
예제 #2
0
    def extlen(self, orghash, msglen, imsg):
        # 按照给定的格式(>IIIII)解析字节流string,返回解析出来的tuple
        hs = struct.unpack(">IIIII", orghash.decode('hex'))


        #更改加密算法的初始值
        self.h0 = hs[0]
        self.h1 = hs[1]
        self.h2 = hs[2]
        self.h3 = hs[3]
        self.h4 = hs[4]

        self.mesg = imsg
        tempmsg = c28.padding(msglen) + imsg  # 计算出一个填充值使得 key + message + padding == 512 bits 的整数倍
        self.lmsg = msglen + len(tempmsg)
        return tempmsg