You are here

public function EncryptPortability::testDecryptingRandomValue in Encrypt 7.2

Same name and namespace in other branches
  1. 7.3 encrypt.test \EncryptPortability::testDecryptingRandomValue()

Test off-the-cuff decrypting of a value using decrypt().

Generate some random text and parameters.

File

./encrypt.test, line 125
Tests for the project Encrypt.

Class

EncryptPortability
Various tests that ensure our encrypted data is portable.

Code

public function testDecryptingRandomValue() {

  // Generate some text and encrypt it.
  $text = $this
    ->randomName(10);
  $encrypted = encrypt($text, array(), 'mcrypt_aes_cbc', 'drupal_variable');
  $encrypted_array = unserialize($encrypted);

  // First, just check to see that the value was actually encrypted.
  $this
    ->assertNotEqual($text, $encrypted_array['text'], t('The value was actually encrypted.'));

  // Attempt to decrypt it without using the encryption array.
  $decrypted = decrypt($encrypted_array['text'], array(), NULL, NULL, 'default');
  $this
    ->assertEqual($text, $decrypted, t('The value was successfully decrypted.'));
}