#16
  1. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,115
    Rep Power
    9398
    Originally Posted by MaryG
    The result for example of number '263524133'
    is 6.2284564758744E+22
    ( I suppose that it is not really easy to break it .. )
    Impossible, even. But you can't reverse it to get the original phone number either so it doesn't do you any good.
  2. #17
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0
    Originally Posted by gw1500se
    On further reflection I guess technically you are encrypting rather than encoding. However, what is obscure is what your point is with respect to the goal. Your technique could work for text if you were to encode it first so that your string was only numbers. But you would also need to break it up such that when you encrypt, the resulting number does not overflow.
    Oh yes that is a very nice solution !!! I 'll try to work on it , and will post the results . Thanks !!
  4. #18
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0
    Originally Posted by requinix
    Impossible, even. But you can't reverse it to get the original phone number either so it doesn't do you any good.
    Hello , thanks for reply

    If you 'll try this script

    PHP Code:
    <?php 

    $tel
    $_POST['text']; 
    $encode= ( $tel *236352413153374 ) + 42847625224 

    if ( 
    $tel ) { 
    echo 
    $encode 


    echo 
    '</br>' 

    $decode = ( $encode 42847625224 ) / 236352413153374 ;  
    echo 
    $decode 

    ?> 

    <form name="test" method="post" action="#"> 
    <textarea name="text" cols="50" rows="4" id="detail"></textarea> 
    <input type="submit" name="Submit" value="Submit">  
    </form>

    By :

    $decode = ( $encode - 42847625224 ) / 236352413153374 ;
    echo $decode ;

    you will see that it works perfect , and the original number is printed
  6. #19
  7. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,115
    Rep Power
    9398
    Well color me surprised. I thought 2363524131297430434471850 would be too high to represent accurately. Maybe for a 32-bit system?
  8. #20
  9. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi MaryG,

    yeah, addition and subtraction as well as multiplication and division are indeed reverse operations. But I guess we all knew that already.

    I'm sorry, but I don't see the point in putting all those big words like "cryptography", "encryption" etc. on some basic math exercises and string substitutions. If you're really interested in cryptography, read up on this topic and try to implement the algorithms yourself, starting with simple things like the already mentioned Caesar cipher. If you really want to make your site secure, use actual encryption through SSL (like ManiacDan already said).

    But calling this "encryption" is like hitting a cooking pot a few times and saying that you want to explore the art of music. It would be more ... honest if you'd simply say that you want to play around with strings a bit to see how they work or something.
    Last edited by Jacques1; November 16th, 2012 at 07:19 PM.
  10. #21
  11. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    Originally Posted by requinix
    Well color me surprised. I thought 2363524131297430434471850 would be too high to represent accurately. Maybe for a 32-bit system?
    The max for a 64 bit system is:
    18,446,744,073,709,551,615

    Mary's number:
    2,363,524,131,297,430,434,471,850

    That is indeed larger. Don't know what's going on there.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  12. #22
  13. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,115
    Rep Power
    9398
    Ah, figured it out. There is inaccuracy with the large number, but because the multiplication and division is also with a large number that inaccuracy gets rounded off.

    (2363524131297430434471849 - 42847625224) / 236352413153374 =
    PHP: 9999999999
    Actual: 9999999998.9999999999999957690299
  14. #23
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0
    Ok , I found a way to define the order of characters, actually it is simplier that I thought .. I''ll play in this way to see what can be done ..


    PHP Code:
    $input $_POST['text'];


    if ( 
    $input{0} == 'a') {
            
    $a '23434';
            echo 
    $a;
        }
     if ( 
    $input{0} == 'b') {
            
    $b '23134';
            echo 
    $b;
        } 

    if ( 
    $input{1} == 'a') {
            
    $a1 '13434';
            echo 
    $a1;
        }
     if ( 
    $input{1} == 'b') {
            
    $b1 '23132';
            echo 
    $b1;
        } 
  16. #24
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0
    The limitations I suppose are ;
    1. The script will be too long
    2. Input characters will have max length
  18. #25
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0
    Originally Posted by gw1500se
    ..Your technique could work for text if you were to encode it first so that your string was only numbers.
    The solution to encode the text into numbers can be something like this ( I suppose );

    PHP Code:
    <?php

    //Define 
    define 'ALPHA' '1' );
    define 'BETA' '2' );
    define 'AALPHA' '3' );
    define 'ABETA' '4');

    $input $_POST['text'];

    //Encode --------------------------
    // First Character Possibilities 
    if ( $input{0} == 'a') { 
    $in0 ALPHA 

    if ( 
    $input{0} == 'b') { 
    $in0 BETA 
    }  

    // Second Character Possibilities
    if ( $input{1} == 'a') { 
    $in1 AALPHA

    if ( 
    $input{1} == 'b') { 
    $in1 ABETA



    //result


    echo  $in0 $in1;

        

    echo 
    '<br>';    
    //Decode ---------------------------    
    //First character Possibilities
        
    if ( $in0 == ALPHA ) {
    $out0 'a';
    }
    if ( 
    $in0 == BETA) {
    $out0 'b' ;
    }

    // Second Character Possibilities

    if ($in1 == AALPHA ){
    $out1 'a';
    }
    if ( 
    $in1 == ABETA ){
    $out1 'b';
    }

    //Result
    echo $out0 $out1;

    ?>


    <form name="test" method="post" action="#">
    <textarea name="text" cols="50" rows="4" id="detail"></textarea>
    <input type="submit" name="Submit" value="Submit"> 
    </form>
  20. #26
  21. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    If you'd read the replies (especially #3) you might come to a better solution.

    Writing down each translation for each possible character at each position has little to do with programming. It's rather a typing exercise.

    PHP has more functionalities than "if" statements and variable assignments. There are also loops and functions like strtr() or chr() and ord().
  22. #27
  23. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0
    Originally Posted by Jacques1
    If you'd read the replies (especially #3) you might come to a better solution.

    Writing down each translation for each possible character at each position has little to do with programming. It's rather a typing exercise.

    PHP has more functionalities than "if" statements and variable assignments. There are also loops and functions like strtr() or chr() and ord().
    As I 've written before , I am not about to use php functions .
    I didn't ask ''which function to use in order to encode a text'' but "how I will separately encode characters from input form "(I am looking for a way to make this works even I will submit 'ab') ... thanks for the reply but it has nothing to do with my first question . Neither I am looking for a way to 'encode' passwords if you are worry for the security .md5() works perfect for this. Functions are the easy solution for encoding....
  24. #28
  25. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    I didn't ask ''which function to use in order to encode a text'' but "how I will separately encode characters from input form "(I am looking for a way to make this works even I will submit 'ab')
    Are you trying to say that you're writing a PHP script which does not use PHP? That is, are you attempting to write a PHP script entirely without function calls? If so, don't post in the PHP forum, post in the general fora (either "Other" or the "Lounge").

    My solution provided you with exactly what you need, except it used str_split. If you have some moral objection to functions for a reason which you're incapable of explaining, do this:

    PHP Code:
    for ( $p 0$p 999999999$p++ ) {
      if ( 
    $input[p] ) {
        switch ( 
    $input[$p] ) {
           case 
    'a':
               echo 
    '0001';
               break;
           case 
    'b':
               echo 
    '0010';
               break;
           
    //etc;
        
    }
      }

    It's very difficult to write a program in a language without using that language. Pseudocode only works as a thought exercise. my first example used str_split. This one I just gave you would be infinitely faster and more efficient (and more correct) using strlen() and/or isset().
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  26. #29
  27. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Sorry, MaryG, but now it's really getting weird. I do understand that you don't want to just call some ready-made function that will return the fully encoded string. You want to implement the encoding yourself. But if you refuse to use even basic functions and maybe even loops, I have no idea what you're here for. Obviously not for programming.

    Going through each possible combination and encoding each character "by hand" is not programming. It's a typing exercise or maybe a weird hobby.

    Every one of the existing hashing/encoding/encryption functions uses other functions internally. That's simply how programming works. You have a "host language", and you use its functionalities (operators, functions, control structures etc.) to implement a certain algorithm.

    I don't even understand why you specifically picked functions. So operators like "==" are OK, but a function like "equals()" would be bad?

    To put it bluntly: I think you have a lot of weird and naive ideads in your head that will stand in your way if you really want to do programming. So you might wanna get clear about what you actually want to do. It might also be a good idea to forget this encoding stuff for a while and move on with your actual website.

    Don't get me wrong: You can do whatever you want, and I don't want to discourage you from doing it. But image you're in a math forum, and somebody says he wants to learn linear algebra. But he refuses to do multiplications and instead has come up with a big table where he calculates products through addition:

    1 * 1 = 1
    2 * 1 = 1 + 1 = 2
    3 * 1 = 1 + 1 + 1 = 3
    ...

    Would you say: "Hey, great idea. Here are the next 100 results for your table ...". Or wouldn't you rather say: "Wait a minute, this makes no sense. What you are trying to do?"

    Your current encoding approach is equivalent to this product table.
  28. #30
  29. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0
    Ok , if you are thinking that creating something different using php is not php , I 'm leaving this forum , to find one less staid

IMN logo majestic logo threadwatch logo seochat tools logo