Skip to content

Commit

Permalink
Add bin2blob & blob2bin php scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ravomavain committed Nov 30, 2011
1 parent 17a7858 commit e378c2d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")));'

2 changes: 2 additions & 0 deletions bin2blob
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/php
<?php echo "0x".bin2hex(file_get_contents("php://stdin")); ?>
2 changes: 2 additions & 0 deletions blob2bin
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/php
<?php echo pack("H*" , preg_replace(array("/^0x/i","/[^0-9A-F]/i"),"",file_get_contents("php://stdin"))); ?>

0 comments on commit e378c2d

Please sign in to comment.