/** * @covers Base32Hex::encode() * @covers Base32Hex::decode() * @covers Base32Hex::encodeUpper() * @covers Base32Hex::decodeUpper() */ public function testRandom() { for ($i = 1; $i < 32; ++$i) { for ($j = 0; $j < 50; ++$j) { $random = \random_bytes($i); $enc = Base32Hex::encode($random); $this->assertSame($random, Base32Hex::decode($enc)); $enc = Base32Hex::encodeUpper($random); $this->assertSame($random, Base32Hex::decodeUpper($enc)); } } }
public function testVectorBase32Hex() { $this->assertSame(Base32Hex::encode(''), ''); $this->assertSame(Base32Hex::encode('f'), 'co======'); $this->assertSame(Base32Hex::encode('fo'), 'cpng===='); $this->assertSame(Base32Hex::encode('foo'), 'cpnmu==='); $this->assertSame(Base32Hex::encode('foob'), 'cpnmuog='); $this->assertSame(Base32Hex::encode('fooba'), 'cpnmuoj1'); $this->assertSame(Base32Hex::encode('foobar'), 'cpnmuoj1e8======'); $this->assertSame(Base32Hex::encodeUpper(''), ''); $this->assertSame(Base32Hex::encodeUpper('f'), 'CO======'); $this->assertSame(Base32Hex::encodeUpper('fo'), 'CPNG===='); $this->assertSame(Base32Hex::encodeUpper('foo'), 'CPNMU==='); $this->assertSame(Base32Hex::encodeUpper('foob'), 'CPNMUOG='); $this->assertSame(Base32Hex::encodeUpper('fooba'), 'CPNMUOJ1'); $this->assertSame(Base32Hex::encodeUpper('foobar'), 'CPNMUOJ1E8======'); }