Last active
March 17, 2024 22:29
-
-
Save hutt/8978333 to your computer and use it in GitHub Desktop.
Convert string to binary / binary to string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/******************************* | |
* | |
* Convert Text to Binary ASCII | |
* oder so. | |
* | |
*******************************/ | |
header("Content-Type: text/html; charset=utf-8"); | |
function textBinASCII($text){ | |
$bin = array(); | |
for($i=0; strlen($text)>$i; $i++) | |
$bin[] = decbin(ord($text[$i])); | |
return implode(' ',$bin); | |
} | |
function ASCIIBinText($bin){ | |
$text = array(); | |
$bin = explode(" ", $bin); | |
for($i=0; count($bin)>$i; $i++) | |
$text[] = chr(bindec($bin[$i])); | |
return implode($text); | |
} | |
?> |
Thank for code, I completed my secure Crypto PHP
Thanks!!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
very good.