You are here

protected function UbercartEncryption::convertKey in Ubercart 7.3

Converts encryption key into an array of numbers.

Parameters

$key: Encryption key.

Return value

Array of integers.

2 calls to UbercartEncryption::convertKey()
UbercartEncryption::decrypt in uc_store/classes/encrypt.inc
Decrypts cyphertext.
UbercartEncryption::encrypt in uc_store/classes/encrypt.inc
Encrypts plaintext.

File

uc_store/classes/encrypt.inc, line 243
Utility class definition.

Class

UbercartEncryption
Handles encryption of credit-card information.

Code

protected function convertKey($key) {
  if (empty($key)) {

    // Commented out to prevent errors getting logged for use cases that may
    // have variable encryption/decryption requirements. -RS
    // $this->errors[] = 'No value has been supplied for the encryption key';
    return;
  }
  $array[] = strlen($key);
  $tot = 0;
  for ($i = 0; $i < strlen($key); $i++) {
    $char = substr($key, $i, 1);
    $num = strpos(self::$scramble1, $char);
    if ($num === FALSE) {
      $this->errors[] = t('Key contains an invalid character (@char)', array(
        '@char' => $char,
      ));
      return;
    }
    $array[] = $num;
    $tot = $tot + $num;
  }
  $array[] = $tot;
  return $array;
}