简体   繁体   English

带加密密钥的PHP加密的Java等效项

[英]Java equivalent for PHP crypt with crypt key

I am trying to find a java equivalent for PHP crypt() function. 我正在尝试为PHP crypt()函数找到一个Java等效项。 I found it here , but the answer says nothing about crypting with a crypt key. 我在这里找到它,但是答案没有说明使用密钥进行加密。 I have a PHP website which uses md5 encryption and I have a datatable for users with their passwords encrypted like this 我有一个使用md5加密的PHP网站,并且有一个用户数据表,其密码像这样加密

crypt($password, CRYPT_KEY)

with CRYPT_KEY being a constant. CRYPT_KEY为常数。 Now I need to use that same datatable for a project in Java. 现在,我需要在Java项目中使用相同的数据表。 How can I use the Java digest function (or any other md5 encyption function) with a crypt key? 如何将Java摘要功能(或任何其他md5加密功能)与密钥一起使用?

Which hashing algorithm does your combination of php-version/platform use? 您的php-version / platform组合使用哪种哈希算法? php's crypt() can choose from a number of algorithms as detailed here: http://php.net/manual/en/function.crypt.php php的crypt()可以从以下详细说明的多种算法中进行选择: http : //php.net/manual/en/function.crypt.php

The commons-codec from Apache has a class Crypt that implements this functionality. Apache的commons-codec具有实现此功能的类Crypt As of version 1.10, it supports these algorithms: 从1.10版开始,它支持以下算法:

  • CRYPT_SHA512
  • CRYPT_SHA256
  • CRYPT_MD5
  • CRYPT_STD_DES

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

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