You are here

public function OpenSSLEncryption::decrypt in Ubercart 8.4

Decrypts cyphertext.

Parameters

string $key: Key used for encryption.

string $cyphertext: String containing text to be encrypted.

Return value

string Plaintext. Decrypted text.

Overrides EncryptionInterface::decrypt

File

uc_store/src/OpenSSLEncryption.php, line 85

Class

OpenSSLEncryption
Provides encryption and decryption using OpenSSL.

Namespace

Drupal\uc_store

Code

public function decrypt($key, $cyphertext) {
  $iv = hex2bin(substr($cyphertext, 0, 32));
  $decrypted = openssl_decrypt(base64_decode(substr($cyphertext, 32)), $this->cypher, $key, OPENSSL_RAW_DATA, $iv);
  if (FALSE === $decrypted) {
    $this->errors[] = t('Unknown error decrypting plaintext.');
  }
  return $decrypted;
}