PHP Classes

File: tests/Backend/FIPSCryptoTest.php

Recommend this page to a friend!
  Classes of Scott Arciszewski   Cipher Sweet   tests/Backend/FIPSCryptoTest.php   Download  
File: tests/Backend/FIPSCryptoTest.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Cipher Sweet
Encrypt data in away that can be searched
Author: By
Last change:
Date: 5 years ago
Size: 862 bytes
 

Contents

Class file image Download
<?php
namespace ParagonIE\CipherSweet\Tests\Backend;

use
ParagonIE\CipherSweet\Backend\FIPSCrypto;
use
ParagonIE\CipherSweet\KeyProvider\ArrayProvider;
use
ParagonIE\CipherSweet\KeyProvider\RandomProvider;
use
PHPUnit\Framework\TestCase;

/**
 * Class FIPSCryptoTest
 * @package ParagonIE\CipherSweet\Tests
 */
class FIPSCryptoTest extends TestCase
{
   
/**
     * @throws \Exception
     */
   
public function testEncrypt()
    {
       
$fips = new FIPSCrypto();
       
$keyProvider = new ArrayProvider($fips, [
           
ArrayProvider::INDEX_SYMMETRIC_KEY => random_bytes(32)
        ]);

       
$message = 'This is just a test message';
       
$cipher = $fips->encrypt($message, $keyProvider->getSymmetricKey());
       
$decrypted = $fips->decrypt($cipher, $keyProvider->getSymmetricKey());

       
$this->assertSame($message, $decrypted);
    }
}