Alternc  3.2
Alternc logiel libre pour l'hébergement
 All Data Structures Namespaces Files Functions Variables Pages
m_crypto.php
Go to the documentation of this file.
1 <?php
2 
3 class m_crypto
4 {
5  function encrypt($sValue, $sSecretKey)
6  {
7  return rtrim(
8  base64_encode(
9  mcrypt_encrypt(
10  MCRYPT_RIJNDAEL_256,
11  $sSecretKey, $sValue,
12  MCRYPT_MODE_ECB,
13  mcrypt_create_iv(
14  mcrypt_get_iv_size(
15  MCRYPT_RIJNDAEL_256,
16  MCRYPT_MODE_ECB
17  ),
18  MCRYPT_RAND
19  )
20  )
21  ), "\0"
22  );
23  }
24 
25  function decrypt($sValue, $sSecretKey)
26  {
27  return rtrim(
28  mcrypt_decrypt(
29  MCRYPT_RIJNDAEL_256,
30  $sSecretKey,
31  base64_decode($sValue),
32  MCRYPT_MODE_ECB,
33  mcrypt_create_iv(
34  mcrypt_get_iv_size(
35  MCRYPT_RIJNDAEL_256,
36  MCRYPT_MODE_ECB
37  ),
38  MCRYPT_RAND
39  )
40  ), "\0"
41  );
42  }
43 
44 }