Показать сообщение отдельно

  #2  
Старый 22.01.2007, 02:19
Foster
Познающий
Регистрация: 14.07.2005
Сообщений: 62
Провел на форуме:
348453

Репутация: 6
Отправить сообщение для Foster с помощью ICQ
По умолчанию

и ещё одно... можно ли с помощью пхп шифровать информацию, не хешировать а именно зашифровывать..? например я хочу зашифровать при помощи пароля текст в файле mess.txt а потом таким же образом востановить...
ЗЫ: base64_encode, md5, crypt не предлогать =)

Нашол кое че, да вот помоему чето не робит

PHP код:
// encode function - encodes text to quet sequre text 

// 

function encrypt( &$ftext$fkey='fenyxxxx' ){ 

$prevchr=0

$answ=''


if (
$im strlen($ftext)) { 

$k=0


for(
$i=0;$i<$im;$i++){ 

$thischr ord(substr($ftext,$i,1)) + $prevchr

if(isset(
$fkey[$k])){ 

$key_chr=ord($fkey[$k])+ord($fkey[$k+1])+ord($fkey[$k+2])-ord($fkey[$k+3]);} 

else{
$k=0;$key_chr=ord($fkey[$k]);$fkey=substr($fkey,1).$fkey[0]; 

}; 

$key_chr=$key_chr+$old_chr^$i

$old_chr checkbit($key_chr7) + 

checkbit($key_chr64)*$fkey[1] + 

checkbit($key_chr1)*$fkey[2] + 

checkbit($key_chr32)*$fkey[3] + 

checkbit($key_chr2)*$fkey[4] + 

checkbit($key_chr8)*$fkey[5] + 

checkbit($key_chr128)*$fkey[7] + 

checkbit($key_chr4)*$fkey[6]; 


$k++; $thischr=$thischr+$key_chr

$prevchr checkbit($thischr16) + 

checkbit($thischr64)*

checkbit($thischr1)*

checkbit($thischr32)*

checkbit($thischr2)*16 

checkbit($thischr8)*32 

checkbit($thischr128)*64 

checkbit($thischr4)*128


$answ .= chr($prevchr); 





return 
$answ




// 

// decode function. decodes encoded data 

// 

function decrypt( &$ftext$fkey='fenyxxxx' ){ 

$prevchr=0

$old_prevchr=0

$answ=''


if (
$im strlen($ftext)) { 

$k=0

for(
$i=0;$i<$im;$i++){ 

$thischr ord(substr($ftext,$i,1)); 

if(isset(
$fkey[$k])){$key_chr=ord($fkey[$k])+ord($fkey[$k+1])+ord($fkey[$k+2])-ord($fkey[$k+3]);}else{$k=0;$key_chr=ord($fkey[$k]);$fkey=substr($fkey,1).$fkey[0];}; 


$key_chr=$key_chr+$old_chr^$i

$old_chr checkbit($key_chr7) + 

checkbit($key_chr64)*$fkey[1] + 

checkbit($key_chr1)*$fkey[2] + 

checkbit($key_chr32)*$fkey[3] + 

checkbit($key_chr2)*$fkey[4] + 

checkbit($key_chr8)*$fkey[5] + 

checkbit($key_chr128)*$fkey[7] + 

checkbit($key_chr4)*$fkey[6]; 


$k++; 


$prevchr checkbit($thischr4) + 

checkbit($thischr16)*

checkbit($thischr128)*

checkbit($thischr32)*

checkbit($thischr1)*16 

checkbit($thischr8)*32 

checkbit($thischr2)*64 

checkbit($thischr64)*128

$prevchr=$prevchr-$key_chr

$answ .= chr($prevchr-$old_prevchr); 

$old_prevchr $thischr





return 
$answ




function 
checkbit$num1$num2 ) { 

return ( 
$num1 $num2 ); 



Последний раз редактировалось Foster; 22.01.2007 в 04:14..
 
Ответить с цитированием