diff --git a/legal.module b/legal.module
index e569d1c..cc2110c 100644
--- a/legal.module
+++ b/legal.module
@@ -85,10 +85,10 @@ function legal_menu() {
     'file'             => 'legal.pages.inc',
   );
 
-  $items['legal_accept/%/%'] = array(
+  $items['legal_accept/%/%/%'] = array(
     'title'           => 'Terms and Conditions',
     'page callback'   => 'drupal_get_form',
-    'page arguments'  => array('legal_login', 1, 2),
+    'page arguments'  => array('legal_login', 1, 2, 3),
     'access callback' => TRUE,
     'type'            => MENU_CALLBACK,
   );
@@ -438,7 +438,7 @@ function legal_user_login(&$edit, $account) {
   // by creating a new one time login link and setting it as the destination
   // after the T&Cs have been accepted.
   if (arg(0) == 'user' && arg(1) == 'reset') {
-    $token = drupal_hash_base64(drupal_random_bytes(55));
+    $token = drupal_random_key();
     // This is a new, anonymous-user session.
     $_SESSION['pass_reset_' . $uid] = $token;
     $query = array('destination' => "user/$uid/edit?pass-reset-token=$token");
@@ -457,8 +457,14 @@ function legal_user_login(&$edit, $account) {
     ->execute()
     ->fetchAllAssoc('uid');
   $signatory = array_pop($result);
+  $timestamp = REQUEST_TIME;
+  $hash = user_pass_rehash($signatory->pass, $timestamp, $signatory->login);
 
-  drupal_goto('legal_accept/' . $signatory->uid . '/' . md5($signatory->name . $signatory->pass . $signatory->login), array('query' => $query));
+  drupal_goto("legal_accept/$signatory->uid/$timestamp/" . $hash,
+    array(
+      'query' => $query,
+    )
+  );
 }
 
 /**
@@ -539,7 +545,7 @@ function legal_user_update(&$edit, $account, $category) {
 /**
  * Require registered users to accept new T&C.
  */
-function legal_login($form, $constructor, $uid, $id_hash = NULL) {
+function legal_login($form, $constructor, $uid, $timestamp, $id_hash = NULL) {
   global $language;
 
   // get last accepted version for this account
@@ -572,7 +578,12 @@ function legal_login($form, $constructor, $uid, $id_hash = NULL) {
     '#value' => $uid,
   );
 
-  $form['id_hash'] = array(
+  $form['timestamp'] = array(
+    '#type'  => 'value',
+    '#value' => $timestamp,
+  );
+
+  $form['hash'] = array(
     '#type'  => 'value',
     '#value' => $id_hash,
   );
@@ -608,17 +619,24 @@ function legal_login($form, $constructor, $uid, $id_hash = NULL) {
 }
 
 function legal_login_validate($form, &$form_state) {
+  $values = $form_state['values'];
+
   $result = db_select('users', 'u')
     ->fields('u')
-    ->condition('uid', $form_state['values']['uid'])
+    ->condition('uid', $values['uid'])
     ->range(0, 1)
     ->execute()
     ->fetchAllAssoc('uid');
 
   $account = array_pop($result);
-  $id_hash = md5($account->name . $account->pass . $account->login);
 
-  if ($id_hash != $form_state['values']['id_hash']) {
+  $hash = user_pass_rehash(
+    $account->pass,
+    $values['timestamp'],
+    $account->login
+  );
+
+  if ($hash !== $values['hash']) {
     form_set_error('legal_accept', t('User ID cannot be identified.'));
     drupal_goto();
   }
