Skip to content

Instantly share code, notes, and snippets.

@DrayChou
Created October 17, 2012 03:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DrayChou/3903618 to your computer and use it in GitHub Desktop.
Save DrayChou/3903618 to your computer and use it in GitHub Desktop.
duyoo
<?php
function B($a){
$b = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
if(empty($a)){
return $a;
}
$a = str_split(strval($a));
$k = 0;
$n = array();
while ($k < count($a)) {
$f = strpos($b,$a[$k++]);
$g = strpos($b,$a[$k++]);
$h = strpos($b,$a[$k++]);
$i = strpos($b,$a[$k++]);
$j = $f << 18 | $g << 12 | $h << 6 | $i;
$c = $j >> 16 & 255;
$d = $j >> 8 & 255;
$e = $j & 255;
if($h == 64){
$n[] = chr($c);
}else if($i == 64){
$n[] = chr($c).chr($d);
}else{
$n[] = chr($c).chr($d).chr($e);
}
}
return implode('',$n);
}
if(isset($_POST['a'])){
exit(B($_POST['a']));
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>jQuery: The Write Less, Do More, JavaScript Library</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
</head>
<body>
<input type='input' id='input'/>
<input type='button' value='php' id='php'/>
<input type='button' value='js' id='js'/>
<pre id='value'></pre>
<script type="text/javascript" charset="utf-8" async defer>
function B(a){
var b= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var c,d,e,f,g,h,i,j,k=0,l=0,m="",n=[];
if(!a){
return a;
}
a+="";
do{
f=b.indexOf(a.charAt(k++));
g=b.indexOf(a.charAt(k++));
h=b.indexOf(a.charAt(k++));
i=b.indexOf(a.charAt(k++));
j=f<<18|g<<12|h<<6|i;
c=j>>16&255;
d=j>>8&255;
e=j&255;
if(h == 64){
n[l++] = String.fromCharCode(c)
}else if(i == 64){
n[l++] = String.fromCharCode(c,d)
}else{
n[l++] = String.fromCharCode(c,d,e)
}
}while(k<a.length);
m=n.join("");
return m;
}
$('input#php').click(function(){
$.post('',{a:$('input#input').val()},function(r){
$('pre#value').html(r);
},'html')
});
$('input#js').click(function(){
$('pre#value').html(B($('input#input').val()));
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment