示例#1
0
def dictListEncryptor(dictList, encryptor=xorEnc.encryptorTxtOut("simpleKey")):
    # e = enc.encryptor()
    res = []
    for i in dictList:
        resV = {}
        for j in i:
            if j in encryptedKeys:
                # Need decryption
                resV[j] = encryptor.en(i[j])
                # print encryptor.de(i[j]).encode('gbk')
            else:
                resV[j] = i[j]
        # print resV
        res.append(resV)
    return res
示例#2
0
def importDb(input, username, targetPasswd, password = None):
    dbSysInst = dbSys.dbSysSmart()
    sf = open(input, 'r')
    package = json.load(sf)
    en = enc.encryptorBase64Out(password)
    l = package["add"]
    if (password is None) and package.has_key("encPass"):
        print 'need password for importing'
        return
    if (not (password is None)):
        if unicode(str(md5.new(password).hexdigest())) != package["encPass"]:
            print 'pass not match:', unicode(str(md5.new(password+package["time-duration"]).hexdigest())), package["encPass"]
            return
        else:
            l = listEncryptor.dictListDecryptor(l, en)
    sysUser = service.ufsUser(u'system.user', u'system.pass')
    if userMan.userManager().verifyPasswd(username, targetPasswd, dbSys.dbSysSmart(sysUser).getDb("passwdDb")):
        print 'importing'
        l = listEncryptor.dictListEncryptor(l, xorEnc.encryptorTxtOut(targetPasswd))
        #print l
        l = listEncryptor.setUser(l, username)
        #print l
        dbSysInst.importDb(l)