让字母字符串位置打乱与恢复ASPPHP通用双版本代码

sharembweb 70次浏览

摘要:让字母字符串位置打乱与恢复,ASP代码部分可通过ASP转PHP来进行转换。

原文=sharembweb.com
加密=gzufyjvayv.ndj
解密=sharembweb.com

让字母字符串位置打乱与恢复ASP代码

<%
'************************************************************
'作者:云祥孙 (精通ASP/VB/PHP/JS/Flash,交流合作可联系本人)
'版权:源代码公开,各种用途均可免费使用。 
'创建:2016-01-15
'联系:QQ313801120  交流群35915100(群里已有几百人)    邮箱313801120@qq.com   个人主页 sharembweb.com
'更多帮助,文档,更新 请加群(35915100)或浏览(sharembweb.com)获得
'*                                    Powered By 云祥孙 
'************************************************************

'变量移位
Function variableDisplacement(content, nPass)
    Dim c, i, s, LetterGroup, DigitalGroup, nLetterGroup, nDigitalGroup, nLetterLen, nDigitalLen, nX 
    '字母组
    'LetterGroup="abcdefghijklmnopqrstuvwxyz"
    LetterGroup = "yzoehijklmfgqrstuvpabnwxcd" 
    '字母长
    nLetterGroup = Len(LetterGroup) 
    '数字组
    'DigitalGroup="0123456789"
    DigitalGroup = "4539671820" 
    '数字长
    nDigitalGroup = Len(DigitalGroup) 
    c = "" 
    For i = 1 To Len(content)
        s = Mid(content, i, 1) 
        nLetterLen = InStr(LetterGroup, s) 
        nDigitalLen = InStr(DigitalGroup, s) 
        '字母处理
        If nLetterLen > 0 Then
            nX = nLetterLen + nPass 
            If nX > nLetterGroup Then
                nX = nX - nLetterGroup 
            ElseIf nX <= 0 Then
                'Call Echo("nX",nX & "," & (nLetterGroup - nX) & "/" & nLetterGroup)
                nX = nX + nLetterGroup 
            End If 
            s = Mid(LetterGroup, nX, 1) 
        '数字处理
        ElseIf nDigitalLen > 0 Then
            nX = nDigitalLen + nPass 
            If nX > nDigitalGroup Then
                nX = nX - nDigitalGroup 
            ElseIf nX <= 0 Then
                'Call Echo("nX",nX & "," & (nLetterGroup - nX) & "/" & nLetterGroup)
                nX = nX + nDigitalGroup 
            End If 
            s = Mid(DigitalGroup, nX, 1) 


        End If 
        c = c & s 
    Next 
    variableDisplacement = c 
End Function 
dim code
code="sharembweb.com"
response.Write("原文=" & code & "<hr>")
code=variableDisplacement(code,23)
response.Write("加密=" & code & "<hr>")
code=variableDisplacement(code,-23)
response.Write("解密=" & code & "<hr>")
%> 

让字母字符串位置打乱与恢复PHP代码

<?PHP
//************************************************************
//作者:云祥孙 (精通ASP/VB/PHP/JS/Flash,交流合作可联系本人)
//版权:源代码公开,各种用途均可免费使用。
//创建:2016-01-15
//联系:QQ313801120  交流群35915100(群里已有几百人)    邮箱313801120@qq.com   个人主页 sharembweb.com
//更多帮助,文档,更新 请加群(35915100)或浏览(sharembweb.com)获得
//*                                    Powered By 云祥孙
//************************************************************
//变量移位
function variableDisplacement($content, $nPass){
    $c=''; $i=''; $s=''; $LetterGroup=''; $DigitalGroup=''; $nLetterGroup=''; $nDigitalGroup=''; $nLetterLen=''; $nDigitalLen=''; $nX ='';
    //字母组
    //LetterGroup="abcdefghijklmnopqrstuvwxyz"
    $LetterGroup = 'yzoehijklmfgqrstuvpabnwxcd' ;
    //字母长
    $nLetterGroup = strlen($LetterGroup) ;
    //数字组
    //DigitalGroup="0123456789"
    $DigitalGroup = '4539671820' ;
    //数字长
    $nDigitalGroup = strlen($DigitalGroup) ;
    $c = '' ;
    for( $i = 1 ; $i<= strlen($content); $i++){
        $s = mid($content, $i, 1) ;
        $nLetterLen = instr($LetterGroup, $s) ;
        $nDigitalLen = instr($DigitalGroup, $s) ;
        //字母处理
        if( $nLetterLen > 0 ){
            $nX = $nLetterLen + $nPass ;
            if( $nX > $nLetterGroup ){
                $nX = $nX - $nLetterGroup ;
            }else if( $nX <= 0 ){
                //Call Echo("nX",nX & "," & (nLetterGroup - nX) & "/" & nLetterGroup)
                $nX = $nX + $nLetterGroup ;
            }
            $s = mid($LetterGroup, $nX, 1) ;
            //数字处理
        }else if( $nDigitalLen > 0 ){
            $nX = $nDigitalLen + $nPass ;
            if( $nX > $nDigitalGroup ){
                $nX = $nX - $nDigitalGroup ;
            }else if( $nX <= 0 ){
                //Call Echo("nX",nX & "," & (nLetterGroup - nX) & "/" & nLetterGroup)
                $nX = $nX + $nDigitalGroup ;
            }
            $s = mid($DigitalGroup, $nX, 1) ;


        }
        $c = $c . $s ;
    }
    $variableDisplacement = $c ;
    return @$variableDisplacement;
}
$code='';
$code='sharembweb.com';
echo('原文=' . $code . '<hr>');
$code=variableDisplacement($code,23);
echo('加密=' . $code . '<hr>');
$code=variableDisplacement($code,-23);
echo('解密=' . $code . '<hr>');


?>



<?PHP
//系统函数列表
header("Content-Type: text/html; charset=gb2312");
function InStr($content,$search){
	if( $search!=""){
		if(strstr($content,$search)){
			return strpos($content,$search)+1;
		}else{
			return 0;
		}
	}else{
		return 0;
	}
}
function Mid($content,$nStart,$nLength=-1){
	$nStart--;				//可以从1开始
	if($nLength==-1){
		$nLength=strlen ( $content );
	}else{
		//$nLength--;
	} 
	return substr($content, $nStart, $nLength) ;
}
function UBound($content){
	return count($content)-1;
}

?>

本文版权归作者所有,转摘请注明作者和出处!
作者:云祥孙
首发:http://sharembweb.com

随机内容

表情

共2条评论
  • 网友评论:

    赞一个

    2020-07-24 16:26:24 回复

  • 网友评论:

    学习了

    2020-07-24 16:26:24 回复

友情链接