diff --git a/src/main/php/com/mongodb/Encrypted.class.php b/src/main/php/com/mongodb/Encrypted.class.php new file mode 100755 index 0000000..247723a --- /dev/null +++ b/src/main/php/com/mongodb/Encrypted.class.php @@ -0,0 +1,16 @@ +ciphertext= (string)$ciphertext; + } + + /** @return int */ + public function length() { return strlen($this->ciphertext); } + + /** @return string */ + public function ciphertext() { return $this->ciphertext; } + +} \ No newline at end of file diff --git a/src/main/php/com/mongodb/io/BSON.class.php b/src/main/php/com/mongodb/io/BSON.class.php index ff5147a..9e78b65 100755 --- a/src/main/php/com/mongodb/io/BSON.class.php +++ b/src/main/php/com/mongodb/io/BSON.class.php @@ -1,7 +1,7 @@ length(), 6).$value->ciphertext(); } else if ($value instanceof Traversable || $value instanceof StdClass) { return "\x03".$name."\x00".$this->sections($value); } else if (is_string($value)) { @@ -132,6 +134,7 @@ public function value($name, $bytes, &$offset) { switch ($binary['subtype']) { case 0: case 2: return $value; case 3: case 4: return new UUID($value); + case 6: return new Encrypted($value); default: throw new FormatException('Cannot handle binary subtype '.$binary['subtype']); } } else if ("\x07" === $kind) { // ObjectId diff --git a/src/test/php/com/mongodb/unittest/BSONTest.class.php b/src/test/php/com/mongodb/unittest/BSONTest.class.php index 9d881e0..461b9eb 100755 --- a/src/test/php/com/mongodb/unittest/BSONTest.class.php +++ b/src/test/php/com/mongodb/unittest/BSONTest.class.php @@ -1,7 +1,7 @@