0

目前正在玩liferay,我希望获得用户名和密码。

我可以获得用户名和加密密码,所以我需要解密密码 - 我想我可以这样做:

Company company;
    try {
        company = CompanyUtil.findByPrimaryKey(user.getCompanyId());
        password = Encryptor.decrypt(company.getKeyObj(), password);
    } catch (NoSuchCompanyException e) {
        e.printStackTrace();
    } catch (SystemException e) {
        e.printStackTrace();
    } catch (EncryptorException e) {
        e.printStackTrace();
    }

然而,这会返回一个 encryptorexception,即:

com.liferay.util.EncryptorException: com.liferay.util.EncryptorException: javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher

我也在 liferay 论坛上发帖,但希望这里的人也能提供帮助——我目前正在尝试以钩子形式执行此操作,portlet 会是更好的主意吗?

非常感谢

4

2 回答 2

1

Liferay is hashing passwords, so there's no concept "decrypting" the password: It's technically impossible. You can brute force some matching parts, but not just decrypt it.

See some deeper discussion in the Liferay message boards. (This is too much to copy/paste here)

If you've also posted your question there, please post a link from your to this post (and/or vice version) if your thread adds value to the discussion

于 2011-06-07T21:14:21.343 回答
0

我认为(或希望)Liferay 使用散列来加密密码。在这种情况下,您必须使用相同的方法加密给定的密码并检查保存的密码。

你解密密码的目的是什么?这决定了您将在哪个地方实现这个 - 钩子或 portlet。

于 2011-05-09T10:17:52.770 回答