게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
php 질문 있습니다.
게시물ID : programmer_14402짧은주소 복사하기
작성자 : 대★맛이야
추천 : 0
조회수 : 312회
댓글수 : 1개
등록시간 : 2015/11/12 22:47:14
옵션
  • 본인삭제금지


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
    include_once('./_common.php');
    require_once('./scripts/rc4.class.php');
 
    // The real part, keys are encouraged to be hexadecimal
    // though they don't need to be.
    // 암욜맨 그대여
    $mb_id = $_GET['id']; // ID 받기 
    $key = $_GET['key'];
    if (strcmp('4.1.0', phpversion()) > 0) {
        global $HTTP_GET_VARS;
        $_GET = &$HTTP_GET_VARS;
    }
    if (get_magic_quotes_gpc()) {
        $mb_id = stripslashes($mb_id);
        $mb_password = stripslashes($mb_password);
        $key = stripslashes($key);
    }
    
    $rc4 = new Crypt_RC4; 
    $rc4->setKey($key);
    $rc4->decrypt($mb_id);
    echo($mb_id);
?>
cs

일단 main.php입니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
 
class Crypt_Rc4 {
    var $sarray();
    var $i0;
    var $j0;
    var $_key;
    
    function Crypt_RC4($key = null) {
        if ($key != null) {
            $this->setKey($key);
        }
    }
    function setKey($key) {
       if (strlen($key> 0)
            $this->_key = $key;
    }
 
    function key(&$key) {
        $len= strlen($key);
        for ($this->= 0$this->< 256$this->i++) {
            $this->s[$this->i] = $this->i;
        }
        $this->= 0;
        for ($this->= 0$this->< 256$this->i++) {
            $this->= ($this->+ $this->s[$this->i] + ord($key[$this->i % $len])) % 256;
            $t = $this->s[$this->i];
            $this->s[$this->i] = $this->s[$this->j];
           $this->s[$this->j] = $t;
      }
 
 
        $this->= $this->= 0;
 
 
    }
 
    function crypt(&$paramstr) {
        $this->key($this->_key);
        $len= strlen($paramstr);
 
        for ($c0$c < $len$c++) {
            $this->= ($this->+ 1) % 256;
            $this->= ($this->+ $this->s[$this->i]) % 256;
            $t = $this->s[$this->i];
            $this->s[$this->i] = $this->s[$this->j];
            $this->s[$this->j] = $t;
            $t = ($this->s[$this->i] + $this->s[$this->j]) % 256;
            $paramstr[$c= chr(ord($paramstr[$c]) ^ $this->s[$t]);
        }
    }
    function decrypt(&$paramstr) {
        $this->crypt($paramstr);
    }
}
?>
 
 
cs

그리고 rc4.class.php 입니다. common.php는 sql 접속이니 신경 안쓰셔도 됩니다.

문제는 _GET으로 받아온건 출력이 잘되는데 rc4로 이미 암호화가 되어서 넘어온 파일을 php 상에서 디코딩할 경우에 디코딩이 안되고 인코딩이 한번 더 됩니다... 근데 php상에서 그냥 변수 설정으로 인코딩 디코딩을 다 할경우 다 된다는 점입니다...

왜이럴까요


전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호