From e378c2de28b12634d8158b6e4ec9f1bf880260fa Mon Sep 17 00:00:00 2001 From: Ravomavain Date: Thu, 1 Dec 2011 00:01:31 +0100 Subject: [PATCH] Add bin2blob & blob2bin php scripts --- README.md | 15 +++++++++++++++ bin2blob | 2 ++ blob2bin | 2 ++ 3 files changed, 19 insertions(+) create mode 100755 bin2blob create mode 100755 blob2bin diff --git a/README.md b/README.md index 0c76224..db6a0fb 100644 --- a/README.md +++ b/README.md @@ -39,3 +39,18 @@ Also work with less strict rules: gcc *.c -o huffman *main.c is only a test program* + +## bin2blob & blob2bin + +PHP scripts to convert sql blob data (0xAF49...) to binary data and vice versa. + +Both scripts can be replaced by inline php commands: + +* bin2blob: + + php -r 'echo "0x".bin2hex(file_get_contents("php://stdin"));' + +* blob2bin: + + php -r 'echo pack("H*" , preg_replace(array("/^0x/i","/[^0-9A-F]/i"),"",file_get_contents("php://stdin")));' + diff --git a/bin2blob b/bin2blob new file mode 100755 index 0000000..340a3b7 --- /dev/null +++ b/bin2blob @@ -0,0 +1,2 @@ +#!/bin/php + diff --git a/blob2bin b/blob2bin new file mode 100755 index 0000000..897d762 --- /dev/null +++ b/blob2bin @@ -0,0 +1,2 @@ +#!/bin/php +