Base64DotSlashTest.php 594 B

12345678910111213141516171819202122232425
  1. <?php
  2. use \ParagonIE\ConstantTime\Base64DotSlash;
  3. class Base64DotSlashTest extends PHPUnit_Framework_TestCase
  4. {
  5. /**
  6. * @covers Base64DotSlash::encode()
  7. * @covers Base64DotSlash::decode()
  8. */
  9. public function testRandom()
  10. {
  11. for ($i = 1; $i < 32; ++$i) {
  12. for ($j = 0; $j < 50; ++$j) {
  13. $random = \random_bytes($i);
  14. $enc = Base64DotSlash::encode($random);
  15. $this->assertSame(
  16. $random,
  17. Base64DotSlash::decode($enc)
  18. );
  19. }
  20. }
  21. }
  22. }