홈으로 홈으로 | 무료회원가입 | 아이디/비번찾기 | 즐겨찾기
추천음악방송메인홈1대1상담음악방송청취
okTrot(구독해주세요)
앵콜트로트(구독해주세요)
뽕짝아가씨(구독해주세요)
음악가사 검색
온라이브스토어(앱다운로드)
온라이브(방송등록및청취)
비디오 베스트 50
금영노래방
TJ노래방
유튜브 동영상 다운로드
POP Player
신나는 고스톱
컴퓨터 오목
작은 음악다방
운.영.자.1대1.상담
FAQ\지원.프로그램
Q&A\고.객.지.원

자동러시 웹플레이어신청

보안∵서버∵쿠키
윈도우∵프레임
이미지∵배경
시간∵달력∵계산
상태바∵타이틀바
음악∵영상
폼∵전송∵테이블
키보드∵마우스
효과∵링크∵메뉴
Script∵php
기타
PHP 강좌
윈도우관련팁
웹관련팁
홈페이지제작팁
기본강좌
레지스트리
윈도우서버
리눅스서버
Android
암호화 - 복호화 함수 (쿠키암호)
10년 전
http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=17

쿠키를 암호화할려고 소스를 찾던중에 pscode.com에 가니까 쓸만한 소스가 있어서 퍼왔습니다.

원문출처
--------------

Title: Encrypt/Decrypt Text
Description: This fabulous class encrypts and decrypts any chain of characters, it uses an encryption method without having an exact order neither a fixed size of chain.
This class was developed originally by Kelvin C. Pérez for the language VB and implemented in PHP by Heriberto Mantilla Santamaría.
View online example --> http://hackprotm.webcindario.com/EncryptDemo/Demo.html
This file came from Planet-Source-Code.com...the home millions of lines of source code
You can view comments on this code/and or vote on it at: http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=1760&lngWId=8

The author may have retained certain copyrights to this code...please observe their request and the law by reviewing all copyright conditions at the above URL.

사용예
---------
위에 링크에서 소스 받아서 다운로드 받고 압축을 풀면 includes/EnDecryptText.php
파일이 핵심입니다.

<?
    include_once "EnDecryptText.php";

    $EnDecryptText = new EnDecryptText();

    $s1 = "동서 南北 Abc.";
    $s2 = $EnDecryptText->Encrypt_Text($s1);
    $s3 = $EnDecryptText->Decrypt_Text($s2);

    echo "<xmp>$s1</xmp>";
    echo "<xmp>$s2</xmp>";
    echo "<xmp>$s3</xmp>";
?>

★ 결과 ↓

동서 南北 Abc.
exxBo3077S3247U3196x2941Xg544a3553p4165fXa1N6s17s3757c3281OI544U1105u1666N1683AA782Hgbh
동서 南北 Abc.

★ 특징 ↓

암호화된 글자가 숫자하고 알파벳으로만 구성됨.
암호화된 글자가 그때 그때마다 다름 (새로고침 클릭해 보면 됩니다)

★ 주의사항 ↓
EnDecryptText.php 의 내용중에 Modules:: 글자를 $this-> 로 바꿔야 합니다.
Modules:: 은 첨보는거라서 뭐가 뭔지 모르겠지만, 클래스에서 새끼(?) 함수를
호출하려면 $this->로 해야할것 같아서 그렇게 했는데, 잘되더군요.

★ EnDecryptText.php 수정된 소스 ↓

<?
//*********************************************************//
//*    Reservados todos los derechos HACKPRO TM ?2005    *//
//*-------------------------------------------------------*//
//* NOTA IMPORTANTE                                      *//
//*-------------------------------------------------------*//
//* Si?tase libre para usar esta clase en sus p?inas,  *//
//* con tal de que TODOS los cr?itos permanecen intactos.*//
//* S?o ladrones deshonrosos transmite el c?igo que los *//
//* programadores REALES escriben con dif?ultad y libre- *//
//* mente lo comparten quitando los comentarios y diciendo*//
//* que ellos escribieron el c?igo.                      *//
//*.......................................................*//
//* Encrypts and Decrypts a chain.                        *//
//*-------------------------------------------------------*//
//* Original in VB for:    Kelvin C. Perez.              *//
//* E-Mail:                kelvin_perez@msn.com          *//
//* WebSite:              http://home.coqui.net/punisher *//
//* 수정 By 칼솜 : Modules:: 를 몽땅 $this-> 로 바꿈 *//
//*+++++++++++++++++++++++++++++++++++++++++++++++++++++++*//
//* Programmed in PHP for: Heriberto Mantilla Santamar?. *//
//* E-Mail:                heri_05-hms@mixmail.com        *//
//* WebSite:              www.geocities.com/hackprotm/  *//
//*.......................................................*//
//* IMPORTANT NOTE                                        *//
//*-------------------------------------------------------*//
//* Feel free to use this class in your pages, provided  *//
//* ALL credits remain intact. Only dishonorable thieves  *//
//* download code that REAL programmers work hard to write*//
//* and freely share with their programming peers, then  *//
//* remove the comments and claim that they wrote the    *//
//* code.                                                *//
//*-------------------------------------------------------*//
//*        All Rights Reserved HACKPRO TM ?2005        *//
//*********************************************************//

class EnDecryptText // Create a class of EnDecryptText.
{
  //------------------------------------------------------------------------------------
  // Encrypt a chain of text.
  //------------------------------------------------------------------------------------
  // Parameters
  //------------------------------------------------------------------------------------
  // $cText: Chain to encrypt.
  //------------------------------------------------------------------------------------
  function Encrypt_Text($cText)
  {$eText = $cText;
  // Get a random Number between 1 and 100. This will be the multiplier
  // for the Ascii value of the characters.
  $nEncKey = intval((100 * $this->Rnd()) + 1);
  // Loop until we get a random value betwee 5 and 7. This will be
  // the lenght (with leading zeros) of the value of the Characters.
  $nCharSize = 0;
  $nUpperBound = 10;
  $nLowerBound = 5;
  $nCharSize = intval(($nUpperBound - $nLowerBound + 1) * $this->Rnd() + $nLowerBound);
  // Encrypt the Size of the characters and convert it to String.
  // This size has to be standard so we always get the right character.
  $cCharSize = $this->fEncryptedKeySize($nCharSize);
  // Convert the KeyNumber to String with leading zeros.
  $cEncKey = $this->NumToString($nEncKey, $nCharSize);
  // Get the text to encrypt and it's size.
  $cEncryptedText = '';
  $nTextLenght = strlen($eText);
  // Loop thru the text one character at the time.
  for($nCounter = 1; $nCounter <= $nTextLenght; $nCounter++)
  {// Get the Next Character.
    $cChar = $this->Mid($eText, $nCounter, 1);
    // Get Ascii Value of the character multplied by the Key Number.
    $nChar = ord($cChar) * $nEncKey;
    // Get the String version of the Ascii Code with leading zeros.
    // using the Random generated Key Lenght.
    $cChar2 = $this->NumToString($nChar, $nCharSize);
    // Add the Newly generated character to the encrypted text variable.
    $cEncryptedText .= $cChar2;
  }
  // Separate the text in two to insert the enc
  // key in the middle of the string.
  $nLeft = intval(strlen($cEncryptedText) / 2);
  $cLeft = $this->strleft($cEncryptedText, $nLeft);
  $nRight = strlen($cEncryptedText) - $nLeft;
  $cRight = $this->strright($cEncryptedText, $nRight);
  // Add a Dummy string at the end to fool people.
  $cDummy = $this->CreateDummy();
  // Add all the strings together to get the final result.
  $this->InsertInTheMiddle($cEncryptedText, $cEncKey);
  $this->InsertInTheMiddle($cEncryptedText, $cCharSize);
  $cEncryptedText = $this->CreateDummy() . $cEncryptedText . $this->CreateDummy();
  return $cEncryptedText;
  }

  //------------------------------------------------------------------------------------
  // Decrypt a chain of text.
  //------------------------------------------------------------------------------------
  // Parameters
  //------------------------------------------------------------------------------------
  // $cText: Chain to decrypt.
  //------------------------------------------------------------------------------------
  function Decrypt_Text($cText)
  {$cTempText = $cText;
  $cDecryptedText = '';
  $cText = '';
  // Replace alpha characters for zeros.
  for($nCounter = 1; $nCounter <= strlen($cTempText); $nCounter++)
  {$cChar = $this->Mid($cTempText, $nCounter, 1);
    if ($this->IsNumeric($cChar) == true)
    $cText .= $cChar;
    else
    $cText .= '0';
  }
  // Get the size of the key.
  $cText = $this->strleft($cText, strlen($cText) - 4);
  $cText = $this->strright($cText, strlen($cText) - 4);
  $nCharSize = 0;
  $this->Extract_Char_Size($cText, $nCharSize);
  $this->Extract_Enc_Key($cText, $nCharSize, $nEncKey);
  // Decrypt the Size of the encrypted characters.
  $nTextLenght = strlen($cText);
  // Loop thru text in increments of the Key Size.
  $nCounter = 1;
  do
  {// Get a Character the size of the key.
    $cChar = $this->Mid($cText, $nCounter, $nCharSize);
    // Get the value of the character.
    $nChar = $this->Val($cChar);
    // Divide the value by the Key to get the real value of the character.
    if ($nEncKey > 0) $nChar2 = $nChar / $nEncKey;
    // Convert the value to the character.
    $cChar2 = chr($nChar2);
    $cDecryptedText .= $cChar2;
    $nCounter += $nCharSize;
  }while ($nCounter <= strlen($cText));
  // Clear any unwanted spaces and show the decrypted text.
  return trim($cDecryptedText);
  }

  //------------------------------------------------------------------------------------
  // Extract the Character Size from the middle of the exncrypted text.
  //------------------------------------------------------------------------------------
  // Par?etros
  //------------------------------------------------------------------------------------
  // &$cText:    Cadena.
  // &$nCharSize: Tama? de la cadena.
  //------------------------------------------------------------------------------------
  function Extract_Char_Size(&$cText, &$nCharSize)
  {// Get the half left side of the text.
  $nLeft = intval(strlen($cText) / 2);
  $cLeft = $this->strleft($cText, $nLeft);
  // Get the half right side of the text.
  $nRight = strlen($cText) - $nLeft;
  $cRight = $this->strright($cText, $nRight);
  // Get the key from the text.
  $nKeyEnc = $this->Val($this->strright($cLeft, 2));
  $nKeySize = $this->Val($this->strleft($cRight, 2));
  if ($nKeyEnc >= 5)
    $nCharSize = $nKeySize + $nKeyEnc;
  else
    $nCharSize = $nKeySize - $nKeyEnc;
  $cText = $this->strleft($cLeft, strlen($cLeft) - 2) . $this->strright($cRight, strlen($cRight) - 2);
  }

  //------------------------------------------------------------------------------------
  // Extract the Encryption Key from the middle of the encrypted text.
  //------------------------------------------------------------------------------------
  // Parameters
  //------------------------------------------------------------------------------------
  // &$cText:    Chain.
  // $nCharSize: Length of the chain.
  // &$nEncKey:  Length of the chain encrypt.
  //------------------------------------------------------------------------------------
  function Extract_Enc_Key(&$cText, $nCharSize, &$nEncKey)
  {$cEncKey = '';
  // Get the real size of the text (without the previously
  // stored character size).
  $nLenght = strlen($cText) - $nCharSize;
  // Get the half left and half right sides of the text.
  $nLeft = intval($nLenght / 2);
  $cLeft = $this->strleft($cText, $nLeft);
  $nRight = $nLenght - $nLeft;
  $cRight = $this->strright($cText, $nRight);
  // Get the key from the text.
  $cEncKey = $this->Mid($cText, $nLeft + 1, $nCharSize);
  // Get the numeric value of the key.
  $nEncKey = $this->Val(trim($cEncKey));
  // Get the real text to decrypt (left side + right side).
  $cText = $cLeft . $cRight;
  }

  //------------------------------------------------------------------------------------
  // Just to fool people....never show the real size in the string but we need to know
  // what we used in order to decrypt it so we will store the both in the string but
  // maked.
  //------------------------------------------------------------------------------------
  // Parameters
  //------------------------------------------------------------------------------------
  // $nKeySize: Length of the chain encrypt.
  //------------------------------------------------------------------------------------
  function fEncryptedKeySize($nKeySize)
  {$nLowerBound = 0;
  $nKeyEnc = intval(($nKeySize - $nLowerBound + 1) * $this->Rnd() + $nLowerBound);
  if ($nKeyEnc >= 5)
    $nKeySize = $nKeySize - $nKeyEnc;
  else
    $nKeySize = $nKeySize + $nKeyEnc;
  return $this->NumToString($nKeyEnc, 2) . $this->NumToString($nKeySize, 2);
  }

  //------------------------------------------------------------------------------------
  // Convert a number to string using a fixed size using zeros in front of the real
  // number to match the desired size.
  //------------------------------------------------------------------------------------
  // Parameters
  //------------------------------------------------------------------------------------
  // $nNumber: Chain that n Numbers contains.
  // $nZeros:  Quantity of zeros to add to the chain.
  //------------------------------------------------------------------------------------
  function NumToString($nNumber, $nZeros)
  {// Check that the zeros to fill are not smaller than the actual size.
  $cNumber = trim(strval($nNumber));
  $nLenght = strlen($cNumber);
  if ($nZeros < $nLenght) $nZeros = 0;
  $nUpperBound = 122;
  $nLowerBound = 65;
  for($nCounter = 1; $nCounter <= ($nZeros - $nLenght); $nCounter++)
  {// Add a zero in front of the string until we reach the desired size.
    $lCreated = false;
    do
    {$nNumber = intval(($nUpperBound - $nLowerBound + 1) * $this->Rnd() + $nLowerBound);
    if (($nNumber > 90) && ($nNumber < 97))
      $lCreated = false;
    else
      $lCreated = true;
    }while ($lCreated == false);
    $cChar = chr($nNumber);
    $cNumber = $cChar . $cNumber;
  }
  // Return the resulting string.
  return $cNumber;
  }

  //------------------------------------------------------------------------------------
  // Insert a string in the middle of another.
  //------------------------------------------------------------------------------------
  // Parameters
  //------------------------------------------------------------------------------------
  // &$cSourceText:  Chain.
  // $cTextToInsert: Chain to insert inside $cSourceText.
  //------------------------------------------------------------------------------------
  function InsertInTheMiddle(&$cSourceText, $cTextToInsert)
  {// Get the half left and half right sides of the text.
  $nLeft = intval(strlen($cSourceText) / 2);
  $cLeft = $this->strleft($cSourceText, $nLeft);
  $nRight = strlen($cSourceText) - $nLeft;
  $cRight = $this->strright($cSourceText, $nRight);
  // Insert cTextToString in the middle of cSourceText.
  $cSourceText = $cLeft . $cTextToInsert . $cRight;
  }

  //------------------------------------------------------------------------------------
  //
  //------------------------------------------------------------------------------------
  function CreateDummy()
  {$nUpperBound = 122;
  $nLowerBound = 48;
  for($nCounter = 1; $nCounter <= 4; $nCounter++)
  {$lCreated = false;
    do
    {$nDummy = intval(($nUpperBound - $nLowerBound + 1) * $this->Rnd() + $nLowerBound);
    if ((($nDummy > 57) && ($nDummy < 65)) || (($nDummy > 90) && ($nDummy < 97)))
      $lCreated = false;
    else
      $lCreated = true;
    }while ($lCreated == false);
    $cDummy .= chr($nDummy);
  }
  return $cDummy;
  }

/////////////////////////////////////////////////////////////////////
// Function of chain handling.                                    //
/////////////////////////////////////////////////////////////////////

  //------------------------------------------------------------------------------------
  // Returns a specification number of characters of the left side of a chain.
  //------------------------------------------------------------------------------------
  // Parameters
  //------------------------------------------------------------------------------------
  // $tmp:  Chain.
  // $nLeft: Number of left characters to right.
  //------------------------------------------------------------------------------------
  function strleft($tmp, $nLeft)
  {$len = strlen($tmp);
  if ($nLeft == 0)
    $str = '';
  else if ($nLeft < $len)
    $str = $this->Mid($tmp, 1, $nLeft);
  return $str;
  }

  //------------------------------------------------------------------------------------
  // Returns a specification number of characters of the right side of a chain.
  //------------------------------------------------------------------------------------
  // Parameters
  //------------------------------------------------------------------------------------
  // $tmp:    Chain.
  // $nRight: Number of right characters to left.
  //------------------------------------------------------------------------------------
  function strright($tmp, $nRight)
  {$len = strlen($tmp);
  if ($nRight == 0)
    $str = '';
  else if ($nRight < $len)
    $str = $this->Mid($tmp, $len - $nRight + 1, $len);
  return $str;
  }

  //------------------------------------------------------------------------------------
  // Returns a specification number of characters of a chain.
  //------------------------------------------------------------------------------------
  // Parameters
  //------------------------------------------------------------------------------------
  // $tmp:    Chain.
  // $start:  Starting position in the chain.
  // $length: Quantity of left characters to right.
  //------------------------------------------------------------------------------------
  function Mid($tmp, $start, $length)
  {$str = substr($tmp, $start - 1, $length);
  return $str;
  }

/////////////////////////////////////////////////////////////////////
// Functions for handling of numbers.                              //
/////////////////////////////////////////////////////////////////////

  //------------------------------------------------------------------------------------
  // Generates a Random number.
  //------------------------------------------------------------------------------------
  function Rnd()
  {srand(); // Initialize random-number generator.
  do
  {$tmp = abs(tan(rand()));
  }while (($tmp > "1") || ($tmp < "0"));
  $tmp = $this->Mid($tmp, 1, 8);
  return $tmp;
  }

  //------------------------------------------------------------------------------------
  // Takes the numbers that it is in a chain.
  //------------------------------------------------------------------------------------
  // Parameters
  //------------------------------------------------------------------------------------
  // $tmp: Chain.
  //------------------------------------------------------------------------------------
  function Val($tmp)
  {$length = strlen($tmp);
  $tmp2 = 0;
  for ($i = 1; $i <= $length; $i++)
  {$tmp1 = $this->Mid($tmp, $i, 1);
    if ($this->IsNumeric($tmp1) == 1)
    {$tmp2 .= $tmp1;}
  }
  return intval($tmp2);
  }

  //------------------------------------------------------------------------------------
  // Returns if an expression you can evaluate as a number.
  //------------------------------------------------------------------------------------
  // Parameters
  //------------------------------------------------------------------------------------
  // $cChar: Chain.
  //------------------------------------------------------------------------------------
  function IsNumeric($cChar)
  {$tmp = ord($cChar);
  if (($tmp < 48) || ($tmp > 57))
    $tmp = false;
  else
    $tmp = true;
  return $tmp;
  }
}
?>  

추천추천 : 125 추천 목록
번호 제목
3,012
 텍스트 줄바꿈, 글자자르기 CSS
3,011
 jQuery Mobile에서 유용한 코드 10가지.
3,010
 [PHP] dirname()함수와 $_SERVER 관련 상수들
3,009
 [PHP] 파일 크기, 사이즈 불러오는 함수, filesize()
3,008
 [jQuery] jQuery Quick API
3,007
 [ transition ] 링크 hover 색상 변화 속도 조절
3,006
 PHP 5.3.0 에서 사라진 함수들 대체
3,005
 어떤 파일들이 include 나 require 되었는지 확인하는 함수(get_included_files)
3,004
 PHP 날짜 형식 및 계산하기(날짜 더하고 빼기)
3,003
 jQuery Mobile에서 유용한 코드 10가지.
3,002
 값이 배열 안에 존재하는지 확인하는 in_array함수
3,001
 사용자가 웹브라우저에서 뒤로가기를 했을때 감지하는 방법
3,000
 [jQuery]버튼 활성화, 비활성화
2,999
 jQuery show() / hide() / toggle() 사용법
2,998
 jquery 여러가지 이벤트
2,997
 border-radius 속성
2,996
 네이버 오픈API 음성합성 API 사용하는 PHP 샘플코드
2,995
 UTF8 한글 자르기..
2,994
 iconv 에러 발생시 계속 처리하기 옵션
2,993
 [PHP] 현재 페이지의 도메인 , URL 정보 알아내기.
2,992
 [PHP] 막강 기능 배열..
2,991
 [CSS] - Input clear `X ` 버튼 제거 ( IE, Chrome, Firefox )
2,990
 [Mobile] - 모바일웹 Href 태그속성들
2,989
 [JqueryMobile] - 현재화면의 가로세로 사이즈 구하기
2,988
 [JqueryMobile] - 화면의 가로, 세로 사이즈 구하는 방법
2,987
 jquery로 가로 넓이(width), 세로 높이(height) 자동 조절
2,986
 iframe 높이 jquery로 자동조절하기
2,985
 jQuery 오른쪽 영역의 높이를 왼쪽 영역의 높이와 동일하게 하기
2,984
 jquery에서 테이블 짝수, 홀수 번째 TR 배경색 변경하기
2,983
 jquery에서 테이블에 마우스 오버시 해당 행의 배경색상 변경하기
2,982
 jquery 스크립트내 특정값 확인하기 (디버깅)
2,981
 jquery cookie (jquery.cookie.js)
2,980
 jquery div 기본 넓이, 높이 계산 및 padding, border 포함 하기
2,979
 jquery 다른버전 추가 사용시 충돌 방지 (카페24 스마트디자인 기본내장 jquery 1.4.4 버전과 충돌시 해결방법)
2,978
 특정 페이지 종료시 확인 경고창 출력
목록
추천음악방송
인기절정뽕짝파티
인기트로트모음
지루박디스코메들리
밤무대애창곡
전자올겐경음악
앵콜트로트
뽕짝아가씨
작은 음악다방
종합성인가요방
카바레 음악
트롯디스코팡팡
관광 메들리
트롯카페
가요감상실
추억의옛노래
스페셜가요광장
BillBoard Free
Dance&Remix
추천가요모음
경음악.전자올겐
스페셜음악여행
WOLRD POPs
K-POP\BillBoard
JP\CN
POP TOP BEST
K.R.노래방

추천가요\인기
F뮤직 인기\발라드
F뮤직 애창\트로트
트로트성인가요
인기가요
프리미엄 POP
경음악\기타
프리미엄 최신가요
프리미엄 성인가요
가요1번지(종합)
뮤직하우스
동요\연변\반주\기타
가요축제\트롯1번지
댄스\메들리\리믹스
카페\명상\경음악\기타
추천가요\POP\기타
최신가요\인기가요
뮤직트로트 부산광역시부산진구 가야동 ㅣ 개인정보취급방침
Copyright (C) musictrot All rights reserved.