13 $this->values[
'*'] = $value = $cipher->
encrypt(
'', str_repeat(
"\x00", 16));
14 $this->values[
'$'] = $value = self::doubling($value);
15 for ($i = 0; $i <= 128; $i++) {
16 $this->values[$i] = $value = self::doubling($value);
20 protected static function doubling($value)
22 $codes = array_map(
'ord', str_split($value));
23 $binary = vsprintf(str_repeat(
"%08b", strlen($value)), $codes);
24 $codes = array_map(
'bindec', str_split(substr($binary, 1) .
'0', 8));
27 if (ord($value[0]) & 0x80) {
33 return implode(
'', array_map(
'chr', $codes));
36 public function offsetExists($offset)
38 return isset($this->values[$offset]);
41 public function offsetGet($offset)
43 return isset($this->values[$offset]) ? $this->values[$offset] : null;
46 public function offsetSet($offset, $value)
48 throw new \RuntimeException(
'Cannot set offset');
51 public function offsetUnset($offset)
53 throw new \RuntimeException(
'Cannot unset offset');
encrypt($iv, $data, &$tag=null, $aad= '')
$cipher
Approved block cipher with a 128-bit block size.