예제 #1
0
    def add(self, email, password, ip):
        if self.get(email=email, fields='1') is not None:
            raise self.DeplicateUser('duplicate username')

        now = time.time()
        if isinstance(ip, basestring):
            ip = utils.ip2int(ip)
        userkey = umsgpack.unpackb(crypto.password_hash(password))[0]

        insert = dict(
                email = email,
                email_verified = 0,
                password = crypto.aes_encrypt(
                    crypto.password_hash(password), userkey),
                userkey = crypto.aes_encrypt(userkey),
                nickname = None,
                role = None,
                ctime = now,
                mtime = now,
                atime = now,
                cip = ip,
                mip = ip,
                aip = ip,
                )
        return self._insert(**insert)
예제 #2
0
파일: user.py 프로젝트: Crooky/qiandao
    def add(self, email, password, ip):
        if self.get(email=email, fields='1') is not None:
            raise self.DeplicateUser('duplicate username')

        now = time.time()
        if isinstance(ip, basestring):
            ip = utils.ip2int(ip)
        userkey = umsgpack.unpackb(crypto.password_hash(password))[0]

        insert = dict(
                email = email,
                email_verified = 0,
                password = crypto.aes_encrypt(
                    crypto.password_hash(password), userkey),
                userkey = crypto.aes_encrypt(userkey),
                nickname = None,
                role = None,
                ctime = now,
                mtime = now,
                atime = now,
                cip = ip,
                mip = ip,
                aip = ip,
                )
        return self._insert(**insert)
예제 #3
0
    def add(self, email, password, ip):
        if self.get(email=email, fields='1') is not None:
            raise self.DeplicateUser('duplicate username')

        now = time.time()
        if isinstance(ip, str):
            ip = utils.ip2int(ip)
        userkey = umsgpack.unpackb(crypto.password_hash(password))[0]

        hash = MD5.new()
        hash.update(password.encode('utf-8'))
        password_md5 = hash.hexdigest()

        insert = dict(
            email=email,
            email_verified=0,
            password=crypto.aes_encrypt(crypto.password_hash(password),
                                        userkey),
            userkey=crypto.aes_encrypt(userkey),
            nickname=None,
            role=None,
            ctime=now,
            mtime=now,
            atime=now,
            cip=ip,
            mip=ip,
            aip=ip,
            password_md5=password_md5,
        )
        return self._insert(**insert)
예제 #4
0
    def encrypt(self, id, data):
        if id:
            userkey = self.__getuserkey(id)
        else:
            userkey = config.aes_key

        try:
            return crypto.aes_encrypt(data, userkey)
        except Exception as e:
            raise self.UserDBException('encrypt error')
예제 #5
0
파일: user.py 프로젝트: Crooky/qiandao
    def encrypt(self, id, data):
        if id:
            userkey = self.__getuserkey(id)
        else:
            userkey = config.aes_key

        try:
            return crypto.aes_encrypt(data, userkey)
        except Exception as e:
            raise self.UserDBException('encrypt error')