/** * @covers CryptLib\Core\BaseConverter::convertToBinary * @covers CryptLib\Core\BaseConverter::convertFromBinary * @covers CryptLib\Core\BaseConverter::baseConvert * @dataProvider provideConvertToFromBinary */ public function testConvertToAndFromBinary($str, $from) { return false; $result1 = BaseConverter::convertFromBinary($str, $from); $result = BaseConverter::convertToBinary($result1, $from); $this->assertEquals($str, $result); }
/** * Encrypt the data using the supplied key, cipher * * @param string $data The data to encrypt * * @return string The encrypted data */ protected function encryptBlock($data) { $size = $this->cipher->getBlockSize(); $state = str_pad(BaseConverter::convertToBinary($this->state, '0123456789'), $size, chr(0), STR_PAD_LEFT); $stub = $this->cipher->encryptBlock($state); $this->state = $this->bigMath->add($this->state, 1); return $stub ^ $data; }
/** * Transform a string number into a binary string using base autodetection * * @param string $string The string to transform * * @return string The binary transformed number */ protected function normalize($string) { return BaseConverter::convertToBinary($string, '0123456789'); }