how to encryption and decryption variable in php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rahia307
    New Member
    • Jun 2007
    • 32

    how to encryption and decryption variable in php

    hi

    i wan to encrypt variable and again decrypt. how can i do this if any body have idea about it please help me.
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    Have you never watched spy films.
    You need an encryption key or primer I think in US.
    PHP has encryption functions md5() and sha1() but you cannot de-crypt otherwise they would be useless.
    So you need a user defined algorithm which is your encrption key.
    This can be anything your imagination allows.
    Have fun

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      You could always use the base64_encode and base64_decode functions. But they really are no more secure than plain text.
      Totally useless from a security point of view. They exist mostly to encode binary data before sending them through mail bodies and such.

      Comment

      • mikeschroeder
        New Member
        • Jun 2008
        • 1

        #4
        If you need two way encryption for storing sensitive data or something of the sorts, you could always use the OpenSSL support in php. http://php.net/openssl

        This site has a lot of different examples of the usage:
        Last edited by Atli; Jun 3 '08, 08:08 PM. Reason: Removed the us from the php.net link. Loads faster for the rest of the world that way ;)

        Comment

        Working...