1 | <?php |
---|
2 | /***************************************************************************\ |
---|
3 | * Expresso - Expresso Messenger * |
---|
4 | * - Serge Rehem * |
---|
5 | * - JETI - http://jeti-im.org/ * |
---|
6 | * ------------------------------------------------------------------------- * |
---|
7 | * This code is based on AES Interop Between PHP and Java (Part 1) post at * |
---|
8 | * http://propaso.com/blog/?cat=6 * |
---|
9 | * ------------------------------------------------------------------------- * |
---|
10 | * This program is free software; you can redistribute it and/or modify it * |
---|
11 | * under the terms of the GNU General Public License as published by the * |
---|
12 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
13 | * option) any later version. * |
---|
14 | \***************************************************************************/ |
---|
15 | function encrypt($plain_text , $secret_key) |
---|
16 | { |
---|
17 | $cipher = "rijndael-128"; |
---|
18 | $mode = "cbc"; |
---|
19 | $iv = "@4321avaJtluafeD"; |
---|
20 | $td = mcrypt_module_open($cipher, "", $mode, $iv); |
---|
21 | mcrypt_generic_init($td, $secret_key, $iv); |
---|
22 | $cyper_text = mcrypt_generic($td, $plain_text); |
---|
23 | mcrypt_generic_deinit($td); |
---|
24 | mcrypt_module_close($td); |
---|
25 | return bin2hex($cyper_text); |
---|
26 | } |
---|
27 | ?> |
---|