Base64DotSlashOrderedTest.php 636 B

12345678910111213141516171819202122232425
  1. <?php
  2. use \ParagonIE\ConstantTime\Base64DotSlashOrdered;
  3. class Base64DotSlashOrderedTest extends PHPUnit_Framework_TestCase
  4. {
  5. /**
  6. * @covers Base64DotSlashOrdered::encode()
  7. * @covers Base64DotSlashOrdered::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 = Base64DotSlashOrdered::encode($random);
  15. $this->assertSame(
  16. $random,
  17. Base64DotSlashOrdered::decode($enc)
  18. );
  19. }
  20. }
  21. }
  22. }