From 067008c5f094ba9606daacbe540f6b929dc124ea Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 15:31:28 +0200 Subject: Adding upstream version 1:1.3.2. Signed-off-by: Daniel Baumann --- library/X509/DbTool.php | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 library/X509/DbTool.php (limited to 'library/X509/DbTool.php') diff --git a/library/X509/DbTool.php b/library/X509/DbTool.php new file mode 100644 index 0000000..4049c5a --- /dev/null +++ b/library/X509/DbTool.php @@ -0,0 +1,45 @@ +pgsql = $db->getConfig()->db === 'pgsql'; + } + + /** + * @param string $binary + * + * @return string + */ + public function marshalBinary($binary) + { + if ($this->pgsql) { + return sprintf('\\x%s', bin2hex(static::unmarshalBinary($binary))); + } + + return $binary; + } + + /** + * @param resource|string $binary + * + * @return string + */ + public static function unmarshalBinary($binary) + { + if (is_resource($binary)) { + return stream_get_contents($binary); + } + + return $binary; + } +} -- cgit v1.2.3