简体   繁体   English

CryptographyDeprecationWarning:不推荐使用 int_from_bytes,请改用 int.from_bytes

[英]CryptographyDeprecationWarning: int_from_bytes is deprecated, use int.from_bytes instead

INFO:Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) 
INFO:Started reloader process [27528] using statreload
C:Python\Python39\lib\site-packages\jose\backends\cryptography_backend.py:18:
CryptographyDeprecationWarning: int_from_bytes is deprecated, use int.from_bytes 
instead from cryptography.utils import int_from_bytes, int_to_bytes 
INFO: Started server process [8912]
INFO: Waiting for application startup. 
INFO: Application startup complete.

I am new to FastAPI as I was implementing the JWT token in my project the APIs are working as it should be, but each time I start the server it shows this warning.我是 FastAPI 的新手,因为我在我的项目中实现 JWT 令牌,API 正在正常工作,但每次我启动服务器时都会显示此警告。

I have imported jwt from jose and CryptContext from passlib.context python version 3.9我已经从 jose 导入 jwt,从 passlib.context python 3.9 版导入 CryptContext

I really love to know what is the reason behind this!我真的很想知道这背后的原因是什么!

The deprecation warning is caused by how the python-jose library loads the integer values from bytes.弃用警告是由python-jose库如何从字节加载 integer 值引起的。 This is not related to fastapi, but is an issue in the library you're using.这与 fastapi 无关,但您正在使用的库中存在问题。 However, the issue was fixed in python-jose five days ago (2021-04-29), and will be present in the next release.但是,该问题已在五天前(2021-04-29)在python-jose中修复,并将在下一个版本中出现。

You can see the change in the commit on Github.您可以在 Github 上看到提交中的更改 For now you can ignore the warning, but as soon as an upgraded version of python-jose is released you should upgrade to the new version.现在你可以忽略警告,但是一旦python-jose的升级版本发布,你应该升级到新版本。

Try to upgrade cryptography package to the newest available version尝试将密码学 package 升级到最新的可用版本

python3 -m pip install -U cryptography

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM