odoo15里面密码与附件加密方式

一、odoo里面用户设置的密码加密方式
加密是用【Passlib生成的PBKDF2 SHA512哈希】 加密后位数是128位

`  def _set_password(self):
    ctx = self._crypt_context()
    hash_password = ctx.hash if hasattr(ctx, 'hash') else ctx.encrypt
    for user in self:
        self._set_encrypted_password(user.id, hash_password(user.password))

 def _set_encrypted_password(self, uid, pw):
    assert self._crypt_context().identify(pw) != 'plaintext'

    self.env.cr.execute(
        'UPDATE res_users SET password=%s WHERE id=%s',
        (pw, uid)
    )
    self.invalidate_cache(['password'], [uid])`

二、odoo附件存储加密
附件在写入硬盘之前,odoo会计算文件的sha1值,得到一个校验值:SHA1 是 160 位

posted @ 2022-05-22 07:41  何双新  阅读(382)  评论(0编辑  收藏  举报