Hello, I want to transfer to the hidden input, and, to avoid substitution, I want to transmit encrypted.

Mol sent to the server, decrypted - executed. Preferably with salt. I would like to have standard php functions for working with it. And so as not to stress the server too much :)

Help who can

    2 answers 2

    base64_encode() / base64_decode() 

    UPD (salt):

    1. Take the string that needs to be encoded.
    2. We read each character of this string and convert it to a number (the number in the ASCII table or UNICODE)
    3. We add to the received number (or we subtract) the certain number known only to you.
    4. The set of numbers is converted back to a string.
    • And you can not salt it? Anyway, after all, can it be decrypted in order to transfer someone else's ID, or encrypt another, etc.? - butteff 4:26 pm
    • one
      Well then, I would just advise you to develop your own encoding algorithm. This is done elementary. How to do, in addition to the answer. In general, you asked for a reversible encryption algorithm, I showed it, so the answer would be worth accepting. - AseN
    • Thank you so much - butteff

    mcrypt_ecb encrypts the string with a key.

    Example:

     $key = "это ключ"; $text = "Сообщение, которое должно быть зашифровано"; echo $text; $str = mcrypt_ecb(MCRYPT_DES, $key, $text, MCRYPT_ENCRYPT); echo $str; $decrypted_str = mcrypt_ecb(MCRYPT_DES, $key, $str, MCRYPT_DECRYPT); echo $decrypted_str; 

    And base64 is not encryption, but encoding binary information using the alpha-digital part of the symbol table.