Esempio n. 1
0
def login(password, codeType):
    disk_ = get_disk_ID()

    enCodeA = b''
    enCodeB = b''
    for i in range(32):
        a = toByte(toInt(password[i * 2]) - 2020)
        b = toByte(toInt(password[i * 2 + 1]) - 2020)[::-1]

        enCodeA += a
        enCodeB = b + enCodeB

    trueCode = toString(enCodeA + enCodeB).replace(' ', '')

    if disk_ + passwordData[codeType] == trueCode:
        return True
    else:
        print("硬盘码为:\t" + disk_)
        print("密码不正确已退出")
        return False
Esempio n. 2
0
def indexContentAna(imgIndexContent):
    imgIndexAnaDictA = {}
    imgIndexAnaDictB = {}
    imgIndexAnaDictC = []
    for element in imgIndexContent:
        address = element[:4]
        size = element[4:8]
        name = element[8:]
        index = imgIndexContent.index(element)
        imgIndexAnaDictA[index] = [toInt(address), toInt(size), toString(name)]
        imgIndexAnaDictB[index] = [address, size, name]
        if index == 0:
            imgIndexAnaDictC.append(toInt(size))

        if index > 0:
            if imgIndexAnaDictA[index][0] != imgIndexAnaDictA[index - 1][0]:
                imgIndexAnaDictC.append(toInt(size))
            else:
                imgIndexAnaDictC.append(0)

    return imgIndexAnaDictA, imgIndexAnaDictB, imgIndexAnaDictC
Esempio n. 3
0
 def updateSplitData(self, header, imgCount, dictB, imgContentSplits):
     """
     更新NPK分割内容
     :param header: 文件头
     :param imgCount: IMG数量
     :param dictB: 二进制流IMG词典
     :param imgContentSplits: IMG内容分割
     :return: NPK文件流
     """
     self.allContent = reCombination(header, imgCount, dictB,
                                     imgContentSplits)
     self.imgContents = imgContentSplits
     self.contentSplit = self.splitNpkContent()
     if len(dictB.keys()) > 0:
         dictA = dictB
         for key in dictB.keys():
             dictA[key][0] = toInt(dictB[key][0])
             dictA[key][1] = toInt(dictB[key][1])
             dictA[key][2] = toString(dictB[key][2])
         self.dictAna = dictA
     if len(dictB.keys()) == 0:
         self.dictAna = {}
     return self.allContent
Esempio n. 4
0
def nameAna(filePath):
    """
    仅获取NPK和内部IMG名称的词典
    :param filePath: NPK文件路径
    :return: False为目标文件不为标准NPK文件。npkName, imgNameList = [imgName1, imgName2]
    """
    with open(filePath, 'rb') as npk:
        npkContent = npk.read()
    # self.allContent = npkContent

    if isNPK(npkContent):
        imgCount = abs(toInt(npkContent[16:20]))
        # 获取名称
        npkName = filePath.split("\\")[-1]
        indexContent = npkContent[20:20 + imgCount * 264]
        imgNameList = [
            toString(indexContent[264 * imgIndex:264 * (imgIndex + 1)][8:])
            for imgIndex in range(imgCount)
        ]

        return npkName, imgNameList

    else:
        return False