encrypt/decrypt stuff with with these crazy functions...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    encrypt/decrypt stuff with with these crazy functions...

    Here are two very crazy encrypt and decrtpt functions i made just change around some of the arrays to make it more secure but don't share what u use =]
    lol edited nevermind the title its one function
    PHP Code:
    <?php
    function encrypt_decrypt($str,$encrypt_or_decrypt) {
        
    $txt = array("1"=>"a","2"=>"b","3"=>"c","4"=>"d","5"=>"e","6"=>"f","7"=>"g","8"=>"h","9"=>"i","10"=>"j","11"=>"k","12"=>"l","13"=>"m","14"=>"n","15"=>"o","16"=>"p","17"=>"q","18"=>"r","19"=>"s","20"=>"t","21"=>"u","22"=>"v","23"=>"w","24"=>"x","25"=>"y","26"=>"z",);
        
    $txt2 = array("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"=>"0","26"=>"1",);
        if(
    $encrypt_or_decrypt=="" || $encrypt_or_decrypt=="decrypt") { $encrypt_or_decrypt "decrypt"; } else { $encrypt_or_decrypt "encrypt"; }
        if(
    $encrypt_or_decrypt=="decrypt") { $decrypted str_replace($txt2,$txt,$str); } if($encrypt_or_decrypt=="encrypt") { $encrypted str_replace($txt,$txt2,$str); }
        if(
    $encrypt_or_decrypt=="decrypt") { echo $decrypted; } if($encrypt_or_decrypt=="encrypt") { echo $encrypted; }
        } 
        
    /// <- lets test the function now -> ///
        
    echo "encrypted<br />";
    echo 
    encrypt_decrypt("test","encrypt"); /// <-  to encrypt test to '%.'
    echo "<br />";
        echo 
    "decrypted<br />";
    echo 
    encrypt_decrypt("'%.'","decrypt"); /// <- to decrypt '%.' to test

    //it works :)//

    ?>
    Last edited by kevk3v; 04.06.10, 10:57.
    Mobile chat, iphone chat, android chat, chat, rooms http://www.aiochat.com

    #2
    Nice idea but a few errors :P

    eg: hello would be txt2txt2txt2txt2txt2 :P cos of not putting a $ before txt2

    also instead of hard coding 4 lines or arrays you would be better of changing it to

    function encrypt_str($str,$decrypt) {

    then

    if($decrypt==""){
    return str_replace($txt,$txt2,$str);
    }else{
    return str_replace($txt2,$txt,$str);
    }

    so to encrypt would be something like:
    echo encrypt_str("hello","");
    and to decrypt would be:
    echo encrypt_str("*!%!%%!%%!lh!",1);

    hope this helps

    Comment


      #3
      professional advice. always use php's time tested encryption functions. There are many to choose from. If u want to send encrypted data that cnt be easily decrypted by gurus then be wiser.

      Comment


        #4
        Originally posted by something else View Post
        Nice idea but a few errors :P

        eg: hello would be txt2txt2txt2txt2txt2 :P cos of not putting a $ before txt2

        also instead of hard coding 4 lines or arrays you would be better of changing it to

        function encrypt_str($str,$decrypt) {

        then

        if($decrypt==""){
        return str_replace($txt,$txt2,$str);
        }else{
        return str_replace($txt2,$txt,$str);
        }

        so to encrypt would be something like:
        echo encrypt_str("hello","");
        and to decrypt would be:
        echo encrypt_str("*!%!%%!%%!lh!",1);

        hope this helps
        yeah that will help, i see my mistake lol $txt2 =/ i'm making a community script with autindex for smileys n stuff lol cool stuff, nd i am adding as much security as i can to it in config.php such as cahnging the encoding/decrypting array i got it working cool it will be free for all the n00bs ofcorse you good coders dont need it... so far i've only made a class.functions.php file with about 100 functions so far lol so far i've coded bud request, private, public photos/videos, ip-country - choose d/m/y like on fb etcetc don't want to create a spoiler here lol =/ but so far its looking good

        but it wont be txt2txt2txt2txt2txt2 btw lol since the str_replace got no quotes :P
        Last edited by kevk3v; 03.06.10, 15:59.
        Mobile chat, iphone chat, android chat, chat, rooms http://www.aiochat.com

        Comment


          #5
          lol i think your find because its a function it will return txt2txt2txt2txt2txt2...... iv got a feeling function variables dont need quotes to be valid php

          I noticed the other day on one of riders scripts he had a function $bud = budres($who,re); or something like that and it was being validated by php

          .... iv just tried it on a server and it did return txt2txt2txt2txt2txt2txt2 :P

          Comment


            #6
            decrypting doesnt work either with the $txt2 fix :P

            Comment


              #7
              Fixed code also added to first post
              PHP Code:
              <?php
              function encrypt_decrypt($str,$encrypt_or_decrypt) {
                  
              $txt = array("1"=>"a","2"=>"b","3"=>"c","4"=>"d","5"=>"e","6"=>"f","7"=>"g","8"=>"h","9"=>"i","10"=>"j","11"=>"k","12"=>"l","13"=>"m","14"=>"n","15"=>"o","16"=>"p","17"=>"q","18"=>"r","19"=>"s","20"=>"t","21"=>"u","22"=>"v","23"=>"w","24"=>"x","25"=>"y","26"=>"z",);
                  
              $txt2 = array("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"=>"0","26"=>"1",);
                  if(
              $encrypt_or_decrypt=="" || $encrypt_or_decrypt=="decrypt") { $encrypt_or_decrypt "decrypt"; } else { $encrypt_or_decrypt "encrypt"; }
                  if(
              $encrypt_or_decrypt=="decrypt") { $decrypted str_replace($txt2,$txt,$str); } if($encrypt_or_decrypt=="encrypt") { $encrypted str_replace($txt,$txt2,$str); }
                  if(
              $encrypt_or_decrypt=="decrypt") { echo $decrypted; } if($encrypt_or_decrypt=="encrypt") { echo $encrypted; }
                  } 
                  
              /// <- lets test the function now -> ///
                  
              echo "encrypted<br />";
              echo 
              encrypt_decrypt("test","encrypt"); /// <-  to encrypt test to '%.'
              echo "<br />";
                  echo 
              "decrypted<br />";
              echo 
              encrypt_decrypt("'%.'","decrypt"); /// <- to decrypt '%.' back to test

              //it works :)//

              ?>
              Mobile chat, iphone chat, android chat, chat, rooms http://www.aiochat.com

              Comment


                #8
                why dont you use this code?
                Advertise your mobile site for FREE with AdTwirl

                Comment


                  #9
                  hmmm... i'll have a look... looks good...
                  Mobile chat, iphone chat, android chat, chat, rooms http://www.aiochat.com

                  Comment


                    #10
                    lol... preety much does the same thing just with a key but its gud..
                    the one i made is simple and you can make it much more secure by changing around the second array
                    Last edited by kevk3v; 04.06.10, 13:11.
                    Mobile chat, iphone chat, android chat, chat, rooms http://www.aiochat.com

                    Comment


                      #11
                      you could implement an encryption key into this which would make it a little more random without you having to understand things like bit shifting, symetric keys and what not. You need 36 characters, sha512 provides a 128 char string. Therefore you could

                      1. take the given key
                      2. sha512 it to 128 chars
                      3. take a random start char from 1 to 92
                      4. count 36 from the start position into an array like you have above
                      5. encrypt text
                      6. send text along with the key and start position

                      your resulting text could look similar too

                      !10{encoded string}--test

                      !10 indicates start position, --test indicates test was the key for the sha512 generator. quite a simple yet effective enhancement. You can bury the key and start position as much as you like, even break them up into 1 or 2 char portions and embed them at specific points only you know.

                      I would use something like that on my own live sites to be honest, its perfectly secure if you do it correctly, and if your as sad as me you'll actually enjoy making it more and more complex.

                      Note: making your own encryption functions isnt insecure, its perfectly fine as long as you do it right. Dont forget things like DES may be more complex than your algo and yet they are deemed insecure, but thats because they method they encrypt data must be made public for people to implement the algo into their languages/applications, meaning people know how they work and can find ways to brute them, a secret algo for private use does not have its internals on display for all to see and work out how to brute it, so as long as you dont make it obvious as to how its done then your secure!

                      this is a bad algo result for e.g.
                      Code:
                      bf!93EA09810967503F67DFFE53F6592232
                      6B228105397F0EA3FD24C74D1B136B12
                      1307DBD9CAA4D5B0$h766Cxx7mnaa5S
                      why ??? well it is, and its quite obvious to decrypt

                      edit: created this post before gum posted, just hit the submit button now im back

                      Comment


                        #12
                        Yeah i know there are freaks who will spend there whole time looking for obvios stuff nd finding a way to decrypt it... some people just don't have lives but thats some ggud info though
                        Mobile chat, iphone chat, android chat, chat, rooms http://www.aiochat.com

                        Comment


                          #13
                          Can anyone tell me a real case when we need to use this encryption methods?

                          By the way, have a look at:

                          Its a SourceCop decryptor.
                          mysterio.al - programming is a functional art

                          Comment

                          Working...
                          X