简体   繁体   English

试图通过php解密我用javav加密的密码

[英]trying to decrypt via php a password that i encrypted with javav

so my java looks like 所以我的java看起来像

String epassword = Crypt.encryptStringToString((String) params.get("password"));

I then store that in a DB. 然后,将其存储在数据库中。 I need to decrypt it with PHP. 我需要用PHP解密它。

Is there a way to do this? 有没有办法做到这一点?

Thanks 谢谢

I assume you are using uk.org.ellery.twiki.Crypt , since that's the only thing that came up when I search on Google for "encryptStringToString java". 我假设您正在使用uk.org.ellery.twiki.Crypt ,因为当我在Google上搜索“ encryptStringToString java”时,这是唯一的问题。

In PHP, you will need to re-implement the class linked here: 在PHP中,您将需要重新实现此处链接的类:

http://svn.foswiki.org/trunk/EncryptedPagesPlugin/uk/org/ellery/twiki/Crypt.java http://svn.foswiki.org/trunk/EncryptedPagesPlugin/uk/org/ellery/twiki/Crypt.java

You're specifically interested in the "decryptString" method. 您对“ decryptString”方法特别感兴趣。

If it helps, looks like it generates a random salt which is stored with the encrypted value in the first 8 bytes, and the algorithm to apply the actual encryption/decryption is "PBEWithMD5AndDES", as provided by the standard Java crypto libraries. 如果有帮助,则看起来它会生成随机盐,并将其与加密值一起存储在前8个字节中,并且如标准Java加密库所提供的那样,应用实际加密/解密的算法为“ PBEWithMD5AndDES”。 However, there's some wrapper code to convert values into hex values and a Base64 string (and vice versa). 但是,有一些包装器代码可以将值转换为十六进制值和Base64字符串(反之亦然)。

Looks like someone has already ported PBEWithMD5AndDES to PHP , so you just need to re-write the Crypt.java file in PHP. 看起来已经有人将PBEWithMD5AndDES移植到PHP了 ,所以您只需要用PHP重写Crypt.java文件即可。

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

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