Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,547
    Thanks
    57
    Thanked 148 Times in 147 Posts

    Encryption Cypher

    PHP Code:
    <?php

    header
    ('Content-Type: text/html; charset=utf-8');
    function 
    ACT_encrypt_cipher($str$key){ 
        if( 
    is_string($str) && is_string($key) ) { 
            
    $str mb_convert_encoding($str'HTML-ENTITIES'"UTF-8");
            
    $sl strlen($str); $kl strlen($key); 
            
    $fk str_split(str_repeat($keyceil($sl/$kl))); 
            
    $es ' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789&;:[]<>!"$%^*_-=+.,/\\()@?\'`'
            
    $ea = array( 'a' => array(), 'm' => array(), 'c' => array()); 
            foreach( 
    str_split$es ) as $key => $char ) { $ea['a'][] = $key$ea['m'][] = md5($char); $ea['c'][] = $char; } 
            
    $ns ''
            
    $sp str_split($str); 
            foreach( 
    $fk as $k => $_char ) { 
                if( ! isset( 
    $sp[$k] ) ) { break; }     
                
    $cm md5($sp[$k]); 
                if( 
    in_array$cm$ea['m'] ) ) { 
                    
    $kk array_keys$ea['m'], $cm ); 
                    if( 
    in_arraymd5($_char), $ea['m'] ) ) { 
                        
    $sk array_keys$ea['m'], md5($_char) ); 
                        
    $n $ea['a'][$kk[0]] - $ea['a'][$sk[0]]; 
                        if( 
    $n )
                            
    $n $n + (strlen($es));    
                        
    $ns .= $es[$n];
                    }else
                        
    $ns .= $_char;
                }else 
                    
    $ns .= $_char;      
            } 
            return 
    $ns
        } 

    function 
    ACT_decrypt_cipher($str$key){ 
        if( 
    is_string($str) && is_string($key) ) { 
            
    $str mb_convert_encoding($str'HTML-ENTITIES'"UTF-8");
            
    $sl strlen($str); $kl strlen($key); 
            
    $fk str_split(str_repeat($keyceil($sl/$kl))); 
            
    $es ' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789&;:[]<>!"$%^*_-=+.,/\\()@?\'`'
            
    $ea = array( 'a' => array(), 'm' => array(), 'c' => array()); 
            foreach( 
    str_split$es ) as $key => $char ) { $ea['a'][] = $key$ea['m'][] = md5($char); $ea['c'][] = $char; } 
            
    $ns ''
            
    $sp str_split($str); 
            foreach( 
    $fk as $k => $_char ) { 
                if( ! isset( 
    $sp[$k] ) ) { break; } 
                
    $cm md5($sp[$k]); 
                if( 
    in_array$cm$ea['m'] ) ) { 
                    
    $kk array_keys$ea['m'], $cm ); 
                    if( 
    in_arraymd5($_char), $ea['m'] ) ) { 
                        
    $sk array_keys$ea['m'], md5($_char) ); 
                        
    $n $ea['a'][$kk[0]] + $ea['a'][$sk[0]];
                        if( 
    $n > (strlen($es)-1) )
                            
    $n $n strlen($es);    
                        
    $ns .= $es[$n];
                    }else
                        
    $ns .= $_char;
                }else 
                    
    $ns .= $_char;      
            } 
            return 
    $ns
        }


    $keyd 's3cr3t';
    $str 'Me `and` my "email" [foo@example.co.uk], website (http://www.example.co.uk) went 4 a\ walk WHICH I might add cost \'0.00\' (or $0.00?).';
    $en ACT_encrypt_cipher($str$keyd); 
    $de ACT_decrypt_cipher($en$keyd);

    echo 
    "<strong>String:</strong>     $str<br />";
    echo 
    "<strong>Encrypted:</strong>  " htmlentities($en) . "<br />"
    echo 
    "<strong>Decrypted:</strong>  $de";

    ?>
    output:

    Code:
    String: Me `and` my "email" [foo@example.co.uk], website (http://www.example.co.uk) went 4 a\ walk WHICH I might add cost '0.00' (or $0.00?).
    
    Encrypted: tM?"I(*G?)6!ZMj%Q/ZH&=W)]Mu%U@\M-*W7bS;&Hc_Jp,1*"Beb1@Tz+e4c8Mu%U@\M-*W7bS/$4*)1?MH";Ht%T,"\Eq&n">?)Q-+1?%L^"Kla1!>gm?2(*hX9?G>H,?Z!0?-I?][x
    
    Decrypted: Me `and` my "email" [foo@example.co.uk], website (http://www.example.co.uk) went 4 a\ walk WHICH I might add cost '0.00' (or $0.00?).
    Website Design Mansfield
    PHP Code:
    function I_LOVE(){function b(&$b='P'){$b.='P';}function a($_){return $_++;}$b='P';define("B",'H');b($b=implode('',array($b=a($b),$b=a(B))));b($b);return $b;}
    echo 
    I_LOVE(); 

  • #2
    New to the CF scene
    Join Date
    Sep 2010
    Location
    Ohio
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Very nice script.

  • #3
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,547
    Thanks
    57
    Thanked 148 Times in 147 Posts
    Cheers, I enjoyed writing it.
    Website Design Mansfield
    PHP Code:
    function I_LOVE(){function b(&$b='P'){$b.='P';}function a($_){return $_++;}$b='P';define("B",'H');b($b=implode('',array($b=a($b),$b=a(B))));b($b);return $b;}
    echo 
    I_LOVE(); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •