ȸ¿ø°¡ÀԡžÆÀ̵ð/ºñ¹øã±â
ȨÀ¸·Î


¾Ïȣȭ - º¹È£È­ ÇÔ¼ö (ÄíÅ°¾ÏÈ£)
16³â Àü
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;
  }
}
?>  

ÃßõÃßõ : 278 Ãßõ ¸ñ·Ï
¹øÈ£ Á¦¸ñ
2,885
input ÀÔ·Â ÇÊµå ¾ÕµÚ °ø¹é ½Ç½Ã°£ Á¦°Å
2,884
Placeholder Æ÷Ä¿½º½Ã °¨Ãß±â
2,883
MySQL Áߺ¹µÈ µ¥ÀÌÅ͸¦ »èÁ¦
2,882
MySQL Áߺ¹ µ¥ÀÌÅÍ È®ÀÎ
2,881
sessionStorage.getItem ¿Í sessionStorage.setItem
2,880
Á¦ÀÌÄõ¸® ·£´ýÀ¸·Î ¹è°æ»ö º¯°æ
2,879
preg match¿¡ °üÇÑ Á¤±Ô½Ä
2,878
Stream an audio file with MediaPlayer ¿Àµð¿À ÆÄÀÏ ½ºÆ®¸®¹Ö Çϱâ
2,877
Audio Streaming PHP Code
2,876
PHP $ SERVER ȯ°æ º¯¼ö Á¤¸®
2,875
Vimeo (ºñ¸Þ¿À) API ¸¦ »ç¿ëÇÏ¿© Ç÷¹À̾î ÄÁÆ®·ÑÇϱâ
2,874
iframe »ç¿ë½Ã ÇÏ´Ü¿¡ ¹ß»ýÇÏ´Â °ø¹é Á¦°Å¹æ¹ý
2,873
¾ÆÀÌÇÁ·¹ÀÓ(iframe) Àüüȭ¸é °¡´ÉÇÏ°Ô Çϱâ
2,872
ºÎÆ®½ºÆ®·¦(bootstrapk)¿¡¼­ »ç¿ëÇÏ´Â class¸í Á¤¸®
2,871
ºÎÆ®½ºÆ®·¦ CSS
2,870
Å©·Ò¿¡¼­ ¸¶Áø Á¶Àý
2,869
PHP ÇöÀç ÆäÀÌÁöÀÇ µµ¸ÞÀθíÀ̳ª urlµîÀÇ Á¤º¸ ¾Ë¾Æ¿À±â
2,868
PHP preg match all()
2,867
PHP ·Î À¥ÆäÀÌÁö ±Ü¾î¿À±â ¸ðµç ¹æ¹ý ÃÑÁ¤¸®!
2,866
[PHP] ¿ø°ÝÁö ÆÄÀÏ ÁÖ¼Ò ³ëÃâ ¾ÈÇÏ°í curl·Î ´Ù¿î·Îµå ¹Þ±â
2,865
PHP ÇÔ¼ö Á¤¸®
2,864
¾ÆÀÌÇÁ·¹ÀÓ(iframe) ºñÀ² À¯ÁöÇϸ鼭 Å©±â Á¶ÀýÇÏ´Â ¹æ¹ý
2,863
PHP ¹è¿­¿¡¼­ ¹«ÀÛÀ§·Î Çϳª »Ì¾ÆÁÖ´Â array rand() ÇÔ¼ö
2,862
PHP Á¤±Ô½Ä Á¤¸®
2,861
PHP Á¤±Ô½ÄÀ» È°¿ëÇÑ ÅÂ±× ¹× ƯÁ¤ ¹®ÀÚ¿­ Á¦°Å ¹× ÃßÃâ ¹æ¹ý
2,860
php Å©·Ñ¸µ ¶Ç´Â ÆÄ½Ì ÇÔ¼ö, Á¤±Ô½Ä ¸ðÀ½
2,859
Á¦ÀÌÄõ¸® ±âº» ¸í·É¾î
2,858
À¥ÆäÀÌÁö °¡·Î ¸ðµå¼¼·Î ¸ðµå ÀνÄÇϱâ
2,857
¸ð¹ÙÀÏ À¥ È­¸é °­Á¦ ȸÀü(°¡·Î¸ðµå °íÁ¤)
2,856
[HTML5]¿¡¼­ frameset ´ëü ¹æ¹ý°ú iframe ¼Ó¼º
¸ñ·Ï
¹ÂÁ÷Æ®·ÎÆ® ºÎ»ê±¤¿ª½Ã ºÎ»êÁø±¸ °¡¾ßµ¿ ¤Ó °³ÀÎÁ¤º¸Ãë±Þ¹æħ
Copyright ¨Ï musictrot All rights reserved.