简体   繁体   English

python cli中的java BCryptPasswordEncoder()等效项是什么?

[英]What is the equivalent of java BCryptPasswordEncoder() in python cli?

I have a spring boot web application without registration page or allowing users to register. 我有一个没有注册页面或不允许用户注册的spring boot Web应用程序。 I'm manually creating passwords using another web spring application which ones gives me encoded password on request. 我正在使用另一个Web Spring应用程序手动创建密码,该应用程序会根据要求提供编码密码。 Using the below link to generate the encoded password: http://www.baeldung.com/spring-security-registration-password-encoding-bcrypt 使用以下链接生成编码密码: http : //www.baeldung.com/spring-security-registration-password-encoding-bcrypt

But i was researching to find an alternate simple python equivalent,so i can use it on the cli easily.? 但是我正在研究寻找替代的简单python等价物,因此我可以在cli上轻松使用它。

I was facing the same problem, but the following worked for me: 我遇到了同样的问题,但是以下方法对我有用:

bcrypt.gensalt(rounds = 10, prefix=b"2a")

This seems to be in sync with the bean BCryptPasswordEncoder in SpringBoot :) 这似乎与SpringBoot中的BCryptPasswordEncoder同步:)

BCrypt is a module in python which can be installed using pip install bcrypt . BCrypt是python中的模块,可以使用pip install bcrypt The equivalent to BCryptPasswordEncoder() would require importing bcrypt as import bcrypt and then executing bcrypt.hashpw(password, bcrypt.gensalt()) to encrypt a password. 与BCryptPasswordEncoder()等效,需要将bcrypt import bcryptimport bcrypt ,然后执行bcrypt.hashpw(password, bcrypt.gensalt())来加密密码。

Source: https://pypi.python.org/pypi/bcrypt/3.1.0 来源: https : //pypi.python.org/pypi/bcrypt/3.1.0

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

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