Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Hash? Or something similar..,

  1. #1
    nterror is offline x10 Sophmore nterror is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    112

    Hash? Or something similar..,

    Maybe I'm looking for something entirely different...

    I want to take a long alphanumeric string, toss it into something like MD5 and have it spit out 32 characters (more or less).

    However, I want to be able to convert it back to the original...

    Is this possible? :nuts:

  2. #2
    xPlozion's Avatar
    xPlozion is offline x10 Elder xPlozion is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    Delaware, USA
    Posts
    872

    Re: Hash? Or something similar..,

    well, if it doesn't matter how long it is, you can use openssl_private_encrypt and openssl_public_decrypt.

    Another way of doing it is by taking a look at mcrypt. mcrypt_encrypt and mcrypt_decrypt

    -xP

  3. #3
    Scoochi2's Avatar
    Scoochi2 is offline x10 Sophmore Scoochi2 is an unknown quantity at this point
    Join Date
    Aug 2008
    Location
    Southport!
    Posts
    185

    Re: Hash? Or something similar..,

    Quote Originally Posted by nterror View Post
    I want to take a long alphanumeric string, toss it into something like MD5 and have it spit out 32 characters (more or less).

    However, I want to be able to convert it back to the original...

    Is this possible? :nuts:
    Not unless your original string has 32 or less characters :p
    Encoding can be done in several ways. The easiest is a simple Caesar Cipher. With one of these, each letter is advanced by a certain number of characters. At the end of the list, it loops back to the start.
    So if a becomes c, c becomes e and so on. z becomes b.

    So the message "Hello, world" would become "Jgnnq yqtnf".
    However, these are pretty easy to figure out. Famous systems such as the Enigma machine are based on this simple concept (although it does it multiple times and has the effect that it maps each character to some seemingly random character.

    To implement this, I would get an ord value for each character in a string, map it to something else (that nothing else is mapped to!!!) and convert it back into ASCII.


    Or there are built in constructs in most languages. In PHP, you can use base64_encode. However, it's pretty easy to decode.
    The most ideal solution is to use a custom made base conversion. Depending on the medium you intend to distribute the encoding string, more bits is better. Add in characters such as <>?:@~;'#[]{} etc on top of the base64 characters.


    In short, there is no way of making an encoded string shorter than the original unless a different character set encoding is used. And then, the encoded set must contain more characters.


    If you need to send people secret messages or anything like that, you could always store messages in a database on a server, giving out only a message number and a password...
    Last edited by Scoochi2; 09-16-2008 at 04:03 PM. Reason: word encryption -> encoding (whoops)
    If anyone can see it, my post was meant for anyone who reads it. Don't take it personally or think I'm being condescending... :nuts:

  4. #4
    xPlozion's Avatar
    xPlozion is offline x10 Elder xPlozion is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    Delaware, USA
    Posts
    872

    Re: Hash? Or something similar..,

    after taking a look at php.net, base64_encode and base64_decode might be your best bet. although I don't know for a fact, as I have never used any of the encryption methods posted, except for md5() and sha1()...

    -xP

  5. #5
    nterror is offline x10 Sophmore nterror is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    112

    Re: Hash? Or something similar..,

    Well I guess compress would have been a better choice of word. It's not for security, but looking for an alternate method to database. But the replies did help since I have something similar planned, thanks.

    For this, users will be filling out a lengthy form, and it will be turned into a file. Would like to compress the information they put in and have it in the file as well.

    At a later time they can simply copy/paste the compressed text and have all the information they put in earlier, reload in the form.

    I guess I said hash earlier since thats that kind of output it reminded me of... :dunno:
    Last edited by nterror; 09-16-2008 at 05:38 PM.

  6. #6
    Scoochi2's Avatar
    Scoochi2 is offline x10 Sophmore Scoochi2 is an unknown quantity at this point
    Join Date
    Aug 2008
    Location
    Southport!
    Posts
    185

    Re: Hash? Or something similar..,

    How about something like this that I made in like... 5 mins. lol
    http://scoochi2.freehostia.com/store/.
    You can save messages, view messages or delete messages.

    When creating, you can choose to have a password for viewing and/or deleting.


    Go ahead. Try it out and see if that's any use for you?
    EDIT: I suddenly realised a security flaw and promptly replaced HTML with custom BBcode
    Last edited by Scoochi2; 09-16-2008 at 06:07 PM. Reason: bye bye HTML :)
    If anyone can see it, my post was meant for anyone who reads it. Don't take it personally or think I'm being condescending... :nuts:

  7. #7
    nterror is offline x10 Sophmore nterror is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    112

    Re: Hash? Or something similar..,

    Actually, that would help.

    What is it using to store the messages?

  8. #8
    Scoochi2's Avatar
    Scoochi2 is offline x10 Sophmore Scoochi2 is an unknown quantity at this point
    Join Date
    Aug 2008
    Location
    Southport!
    Posts
    185

    Re: Hash? Or something similar..,

    All it does it write them to a flat text file. Well, it actually write them to a PHP file as an array which is then required when reading. So it's as simple as showing the value of the array where the key is the message number.
    That's why it gives you a number, and that's why it starts at 0.

    Didn't spend long doing this remember ;)
    A better way of doing it would be to use MySQL. But as you can see it works well with text files as well
    If anyone can see it, my post was meant for anyone who reads it. Don't take it personally or think I'm being condescending... :nuts:

  9. #9
    mattura's Avatar
    mattura is offline x10 Elder mattura is an unknown quantity at this point
    Join Date
    Oct 2007
    Posts
    563

    Re: Hash? Or something similar..,

    just choose your data types carefully and let the database worry about compression!

    If there is a yes/no question, use binary, if a number, use int etc

    You should have a key in the database, then the users can copy/paste that key, and all their info will be retrieved. The key can be an md5 if you like. Or perhaps just an auto-increment field in the database.

    Have you ever seen websites which have 'ULR.com?id=8gbf8567tg8326g8r34' ? This is the unique identifier relating to the person's data. Facebook is a good example.
    Last edited by mattura; 09-18-2008 at 03:42 AM.
    ----
    Life is a game. The conception is terrible but the graphics are amazing!
    matt.elementfx.com

  10. #10
    nterror is offline x10 Sophmore nterror is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    112

    Re: Hash? Or something similar..,

    Thanks again Scoochi. And thanks for the reply mattura.

    Didn't want to store anything, but it seems to be the only way. :pat:

    Closed. (I dont see a checkbox to close the thread, sorry.)
    Last edited by nterror; 09-18-2008 at 09:46 PM.

Closed Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Password hash
    By radofeya in forum Programming Help
    Replies: 4
    Last Post: 06-15-2008, 03:00 PM
  2. Lotus Apache Down? (similar problem from another thread)
    By oyster.admin in forum Free Hosting
    Replies: 1
    Last Post: 03-24-2008, 10:51 AM
  3. Hash Bang
    By rgusarav in forum Free Hosting
    Replies: 1
    Last Post: 12-15-2007, 06:50 PM
  4. Similar hosting sites???
    By live poet in forum Off Topic
    Replies: 8
    Last Post: 02-13-2006, 05:22 PM
  5. MD5 Hash [Cracking Test]
    By Brandon in forum Off Topic
    Replies: 20
    Last Post: 01-02-2006, 09:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers