From 0a6c4e02022a077c5d7fc8f2933ad67835763f1f Mon Sep 17 00:00:00 2001
From: Jake Bell <jake@theunraveler.com>
Date: Wed, 18 May 2011 23:14:16 -0500
Subject: [PATCH 1/2] Basic pass for D7 compatibility.

---
 encrypt.info   |    3 ++-
 encrypt.module |   48 ++++++++++++++++++++++++++----------------------
 2 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/encrypt.info b/encrypt.info
index 3756143..9ffacca 100644
--- a/encrypt.info
+++ b/encrypt.info
@@ -1,3 +1,4 @@
 name = Encrypt
 description = Provides an API for two-way encryption
-core = 6.x
+core = 7.x
+configure = admin/config/system/encrypt
diff --git a/encrypt.module b/encrypt.module
index 5a65b8e..40b8d66 100644
--- a/encrypt.module
+++ b/encrypt.module
@@ -37,6 +37,25 @@ function encrypt_help($path, $arg) {
 }
 
 /**
+ * Implementation of hook_menu().
+ */
+function encrypt_menu() {
+  $items = array();
+
+  $items['admin/config/system/encrypt'] = array(
+    'title' => 'Encrypt',
+    'description' => 'Main settings for encrypt.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('encrypt_admin_settings'),
+    'access arguments' => array('administer encrypt'),
+    'file' => 'includes/encrypt.admin.inc',
+    'type' => MENU_NORMAL_ITEM,
+  );
+
+  return $items;
+}
+
+/**
  * Implementation of hook_theme().
  */
 function encrypt_theme($existing, $type, $theme, $path) {
@@ -51,29 +70,14 @@ function encrypt_theme($existing, $type, $theme, $path) {
 }
 
 /**
- * Implementation of hook_perm().
+ * Implementation of hook_permission().
  */
-function encrypt_perm() {
-  return array('administer encrypt');
-}
-
-/**
- * Implementation of hook_menu().
- */
-function encrypt_menu() {
-  $items = array();
-
-  $items['admin/settings/encrypt'] = array(
-    'title' => 'Encrypt',
-    'description' => 'Main settings for encrypt.',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('encrypt_admin_settings'),
-    'access arguments' => array('administer encrypt'),
-    'file' => 'includes/encrypt.admin.inc',
-    'type' => MENU_NORMAL_ITEM
+function encrypt_permission() {
+  return array(
+    'administer encrypt' => array(
+      'title' => t('Administer Encryption Settings'),
+    ),
   );
-
-  return $items;
 }
 
 /**
@@ -140,6 +144,6 @@ function decrypt($text = '', $options = array(), $method = NULL) {
 function encrypt_encrypt_api() {
   return array(
     'file' => drupal_get_path('module', 'encrypt') . '/includes/encrypt.encrypt.inc',
-    'api version' => '1.0',
+    'api' => '1.0',
   );
 }
-- 
1.7.5.1


From c267bed2d3c389a38a14ab447fca7653911ec363 Mon Sep 17 00:00:00 2001
From: Jake Bell <jake@theunraveler.com>
Date: Thu, 19 May 2011 00:48:17 -0500
Subject: [PATCH 2/2] - Fixed small bug in hook_help switch statement. -
 Refactored a bit.

---
 encrypt.module               |   14 +++++++++-----
 includes/encrypt.encrypt.inc |    7 ++++---
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/encrypt.module b/encrypt.module
index 40b8d66..65e483c 100644
--- a/encrypt.module
+++ b/encrypt.module
@@ -30,10 +30,14 @@ define('ENCRYPT_DEFAULT_METHOD', 'default');
 function encrypt_help($path, $arg) {
   switch ($path) {
     case 'admin/help#encrypt':
-      $output = '<p>'. t('The encrypt module Provides an API for two-way encryption.  Drupal has no native way to do two-way encryption.  PHP\'s ability to do two-way encryption is a little more involved than most people care to get into.  This module provides an easy way to encrypt() and decrypt().') .'</p>';
-  }
+      $output = '<p>'. t('The encrypt module Provides an API for two-way encryption. Drupal has no native way to do two-way encryption. PHP\'s ability to do two-way encryption is a little more involved than most people care to get into.  This module provides an easy way to encrypt() and decrypt().') .'</p>';
+      
+      if (!function_exists('mcrypt_encrypt')) {
+        $output .= '<p>' . t('MCrypt is currently not installed or configured properly on your server. If you would like to use the "MCrypt AES 256" method for encryption, follow the instructions for installing MCrypt !link.', array('!link' => l('here', 'http://www.php.net/manual/en/mcrypt.setup.php'))) . '</p>';
+      }
 
-  return $output;
+      return $output;
+  }
 }
 
 /**
@@ -44,7 +48,7 @@ function encrypt_menu() {
 
   $items['admin/config/system/encrypt'] = array(
     'title' => 'Encrypt',
-    'description' => 'Main settings for encrypt.',
+    'description' => 'Main settings for encryption.',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('encrypt_admin_settings'),
     'access arguments' => array('administer encrypt'),
@@ -75,7 +79,7 @@ function encrypt_theme($existing, $type, $theme, $path) {
 function encrypt_permission() {
   return array(
     'administer encrypt' => array(
-      'title' => t('Administer Encryption Settings'),
+      'title' => t('Administer encryption settings'),
     ),
   );
 }
diff --git a/includes/encrypt.encrypt.inc b/includes/encrypt.encrypt.inc
index 06611e3..0ffebd9 100644
--- a/includes/encrypt.encrypt.inc
+++ b/includes/encrypt.encrypt.inc
@@ -8,7 +8,7 @@
  */
 
 /**
- * Implementation of encrypt_method_info().
+ * Implementation of hook_encrypt_method_info().
  */
 function encrypt_encrypt_method_info() {
   $methods = array();
@@ -113,12 +113,13 @@ function encrypt_encrypt_mcrypt_rij_256($op = 'encrypt', $text = '', $options =
   // Define iv cipher
   $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
   $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
+  $use_base64 = array_key_exists('base64', $options) && $options['base64'] !== FALSE;
 
   // Check op
   if ($op == 'decrypt') {
     // Decrypt
     // Check if we are using base64 encoding
-    if ($options['base64'] !== FALSE) {
+    if ($use_base64) {
       $text = base64_decode($text);
     }
 
@@ -130,7 +131,7 @@ function encrypt_encrypt_mcrypt_rij_256($op = 'encrypt', $text = '', $options =
     $processed_text = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_ECB, $iv);
 
     // Check if we are using base64 encoding
-    if ($options['base64'] !== FALSE) {
+    if ($use_base64) {
       $processed_text = base64_encode($processed_text);
     }
   }
-- 
1.7.5.1

