CRM-13863 - Civi style for ui dialog buttons
[civicrm-core.git] / CRM / Utils / Crypt.php
index dd5e284b8f8041987600573afbd24f27f89574ae..45ffe44651102c5015dd7d323765406f6d06f9e0 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
 class CRM_Utils_Crypt {
 
+  /**
+   * Encrypts a string using AES256 in ECB mode, if encryption is enabled.
+   *
+   * After encrypting the string, it is base64 encoded.
+   *
+   * If encryption is not enabled, either due to CIVICRM_SITE_KEY being
+   * undefined or due to unavailability of the mcrypt module, the string is
+   * merely base64 encoded and is not encrypted at all.
+   *
+   * @param string $string
+   *   Plaintext to be encrypted.
+   * @return string
+   *   Base64-encoded ciphertext, or base64-encoded plaintext if encryption is
+   *   disabled or unavailable.
+   */
   static function encrypt($string) {
     if (empty($string)) {
       return $string;
@@ -56,6 +71,18 @@ class CRM_Utils_Crypt {
     return base64_encode($string);
   }
 
+  /**
+   * Decrypts ciphertext encrypted with AES256 in ECB mode, if possible.
+   *
+   * If the mcrypt module is not available or if CIVICRM_SITE_KEY is not set,
+   * the provided ciphertext is only base64-decoded, not decrypted.
+   *
+   * @param string $string
+   *   Ciphertext to be decrypted.
+   * @return string
+   *   Plaintext, or base64-decoded ciphertext if encryption is disabled or
+   *   unavailable.
+   */
   static function decrypt($string) {
     if (empty($string)) {
       return $string;