简体   繁体   English

如何在 java 中实现 ASP.NET Core Identity 框架的密码哈希

[英]How to implement ASP.NET Core Identity framework's password hasher in java

I am working on a school project where we have an ASP.NET Core web application using Identity framework for our users (they can register and sign in) and we also have to develop a java application where we also have to register and sign in using the same user data as the ASP.NET Core application (mutual db).我正在一个学校项目中工作,我们有一个 ASP.NET Core web 应用程序,使用我们的用户身份框架(他们可以注册和登录),我们还必须开发一个 Z93F725A07423FE1C849F448B33D2F 使用相同的应用程序注册和登录用户数据作为 ASP.NET 核心应用程序(相互数据库)。 Our problem is that Identity hashes their passwords and to be able to sign in or register from our java application we have to compare hashes or hash the same way Identity does.我们的问题是 Identity 对他们的密码进行哈希处理,并且为了能够从我们的 java 应用程序登录或注册,我们必须像 Identity 一样比较哈希值或 hash。 I have been scanning the internet but haven't found a clear answer yet.我一直在扫描互联网,但还没有找到明确的答案。

Now I understand ASP.NET Core Indentity v3 uses现在我了解 ASP.NET Core Indentity v3 使用

PBKDF2 with HMAC-SHA256, 128-bit salt, 256-bit subkey, 10000 iterations带有 HMAC-SHA256 的 PBKDF2,128 位盐,256 位子密钥,10000 次迭代

for hashing their passwords.散列他们的密码。

My question is: what would be the best method of implementing the same hashing method in our java application?我的问题是:在我们的 java 应用程序中实现相同哈希方法的最佳方法是什么? Is there a viable java library available that we can use to mimic the way Identity hashes their passwords?是否有一个可行的 java 库可供我们用来模仿 Identity 散列密码的方式? Or are there better approaches to solve this problem?还是有更好的方法来解决这个问题?

you should just try to override the IPasswordHasher<> interface in the DI of the .net core app and use the same logic in the java app, for reference you can look into this: https://andrewlock.net/migrating-passwords-in-asp-net-core-identity-with-a-custom-passwordhasher/ you should just try to override the IPasswordHasher<> interface in the DI of the .net core app and use the same logic in the java app, for reference you can look into this: https://andrewlock.net/migrating-passwords-in -asp-net-core-identity-with-a-custom-passwordhasher/

one thing to consider, changing the way the hashing is done will make all your existing users locked out unless you migrate them, but since this is a school project i assume that its an acceptable outcome.需要考虑的一件事是,更改散列的完成方式将使所有现有用户被锁定,除非您迁移它们,但由于这是一个学校项目,我认为这是一个可以接受的结果。

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

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