I am encrypting some data from codeigniter using Encrypt class and this will be send to a java program and need to be decoded there.

php code:

    $this->load->library('encrypt');
    $this->encrypt->set_key(SERVER_ENCRYPT_KEY);
    $this->encrypt->set_mode(MCRYPT_MODE_CFB);
    $this->data = $this->encrypt->encode($this->input->post('data'));

where SERVER_ENCRYPT_KEY is the key.

I found this: MCrypt for Java but I could not make it work. There are other libs that can do this? or maybe an example how to do this using the java version of MCrypt.

有帮助吗?

解决方案 2

I decided to avoid CI_Encrypt and use this PHP-Java-AES-Encrypt with small changes: add noise and use 2 types of keys. Also I build a tool to convert the old encrypted data to the new format.

其他提示

Take a look in the CI_Encrypt class. In addition to calling the mcrypt library, it does various non standard things. As an example it runs encrypted data through an own invented _add_cipher_noise method. Also, it seems that the encrypted format have changed with different versions - indicating that this could happen again.

If you are going to use the encrypted data outside codeignite you should not use what looks like codeignites own packaging of mcrypt encrypted data.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top