我有一个 Laravel 网站,它使用 html css 和 js 将所有数据传输到 Hybird 移动应用程序。移动应用程序在离线模式下工作。我必须在基于从网站传输的数据的移动设备中执行身份验证。但是 Laravel 使用 bcrypt 哈希。我如何制作类似的哈希器来匹配 javascript 中的密码?是否可以在 javascript 中制作类似的 hasher 或者有人已经这样做了??
我们继承了一个有 300 万用户登录的系统,在一个 CSV 中分成 500k 块,密码未散列。
客户反对建议,决定他想保留相同的密码,但只是为新系统散列它们,而不是强迫用户设置新密码,所以请不要回复说“不要这样做”。
我们目前正在使用 PHP 来处理文件以规范化数据和 bcrypt 现有的字符串。
然而在 200 条记录上运行测试,当我们将 bcrypt 添加到循环中时,该过程需要大约 7 秒。
随着时间的推移,这显然会增加很多。
有人对我们如何以更快的速度将字符串转换为 bcrypt 有其他建议吗?我在想也许有一个命令行工具,我们可以将 CSV 传递给它,它“知道第 4 列”是密码,并将其散列,然后保存回文件或其他东西。
欢迎在这一点上提出任何建议。
值得一提的是,我们需要在发布当天重复此过程,以便将停机时间降至最低?
非常感谢
更新
对于那些感兴趣的人,在 2012 年的 MBP 上,2.6Ghz i7 和 8GB ram 需要 9 个小时才能完成第一轮,运行 6 个脚本实例,每个实例处理 50 万个用户。
我是 Rails 的新手,并且已经看到了我的问题的所有可能的答案,因为其他开发人员经常问这个问题,但我无法解决它。请看一看。
当我尝试从控制台添加数据时出现此错误
User.create(name: "Michael Hartl", email: "mhartl@example.com", phone: "0123456789", password: "foobar", password_confirmation: "foobar")
Run Code Online (Sandbox Code Playgroud)
错误显示
undefined method `password_digest=' for #<User:0x0000000375c788>
Did you mean? password=
Run Code Online (Sandbox Code Playgroud)
控制器
def create
@candidate = User.new(user_params)
if @candidate.save
flash[:notice] = "New Candidate Added Successfully"
redirect_to(users_path)
else
render('new')
end
end
private
def user_params
#Whitelisting for strng parameters
params.require(:user).permit(:name, :email, :password, :password_confirmation, :qualification, :college, :stream, :phone)
end
Run Code Online (Sandbox Code Playgroud)
移民:
class CreateUsers < ActiveRecord::Migration[5.1]
def change
create_table :users do |t|
t.string :name, null: false
t.boolean :admin_user, default: false
t.string …Run Code Online (Sandbox Code Playgroud) 我有一个 SpringBoot 2.0.1.RELEASE mvc 应用程序,这是我的配置文件
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private Environment env;
@Override
protected void configure(HttpSecurity http) throws Exception {
final List<String> activeProfiles = Arrays.asList(env.getActiveProfiles());
if (activeProfiles.contains("dev")) {
http.csrf().disable();
http.headers().frameOptions().disable();
}
http
.authorizeRequests()
.antMatchers(publicMatchers()).permitAll()
.and()
.formLogin().loginPage("/login").defaultSuccessUrl("/elcordelaciutat/config")
.failureUrl("/login?error").permitAll()
.and()
.logout().permitAll();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
PasswordEncoder encoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
UserDetails userDetails = User.withUsername("elcor")
.password(encoder.encode("elcor"))
.roles("ADMIN")
.build();
auth.inMemoryAuthentication().withUser(userDetails);
}
private String[] publicMatchers() {
/** Public URLs. */
final String[] PUBLIC_MATCHERS = {
"/webjars/**", …Run Code Online (Sandbox Code Playgroud) 如果有人拥有 BCrypt 的加密功能,并加密密码字典并将它们存储在 cd 上。获取对数据库中散列密码的访问权限,他们不应该这样做吗?
我希望答案是否定的。如果是这样,为什么不呢?
构建这个 docker 文件并尝试使用 Bcrypt 来完成一个散列,它会出现段错误,我一生都无法弄清楚为什么。
FROM mhart/alpine-node:9.1.0
MAINTAINER James Claridge <james@claridgeand.co>
RUN mkdir /app
WORKDIR /app
RUN apk --no-cache add --virtual builds-deps build-base python
RUN npm config set python /usr/bin/python
RUN npm i -g npm
RUN npm install
RUN npm rebuild bcrypt --build-from-source
RUN apk del builds-deps
Run Code Online (Sandbox Code Playgroud) 我试图编写一个脚本来将用户添加到 MySQL 数据库中。我终于让所有用户都进入了数据库,但是我的应用程序的登录不会授权他们。我尝试了一系列不同的解决方案,然后我注意到老用户的密码以“$2a”开头,而我添加的密码是“$2b”。所以我插入下面的代码。
password = bcrypt.hashpw(password.encode("UTF-8"), bcrypt.gensalt(11))
password = password.decode("UTF-8")
password = password[:2] + "a" + password[3:] #Why does this work??
Run Code Online (Sandbox Code Playgroud)
突然就可以登录没问题了。那么为什么“$2a”会起作用而不是“$2b”呢?Web 应用程序不是我的,我找不到它检查密码的代码。如果有帮助,webapp 是用 Java 制作的,并使用 spring 进行验证。
我搜索了 Spring 5 Security 的文档,但在$2y$任何地方都找不到对 BCrypt版本前缀的引用。
但是,在查看源代码时,我在以下的Javadoc 中PasswordEncoder找到了一个参考:
可以选择提供“版本”($2a、$2b、$2y)
谁能给我一些共识?$2y$使用 Spring 5 Security 时是否可以使用bcrypt 版本前缀?
PHP password_hash()函数的最大允许成本是多少?
$options = [
'cost' => 18,
];
$res = password_hash("donkey", PASSWORD_BCRYPT, $options);
var_dump($res);
Run Code Online (Sandbox Code Playgroud)
到目前为止,我尝试过这些成本,时间正在迅速攀升。
我尝试了 120 并得到:
指定的 bcrypt 成本参数无效
所以我知道有一个限制,但我没有在 PHP 文档中看到它。有人知道这是什么吗?
如何将加密的密码保存到 MongoDB?
PS 我是一个初学者开发者,仍在学习如何使用 NestJS
bcrypt ×10
php ×3
encryption ×2
spring ×2
alpine-linux ×1
csv ×1
docker ×1
hash ×1
java ×1
javascript ×1
jbcrypt ×1
laravel ×1
nestjs ×1
node.js ×1
postman ×1
python ×1
spring-boot ×1
spring-mvc ×1
typescript ×1
verification ×1