Two way encryption with PHP - some libraries for doing this?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Joshua Beall

    Two way encryption with PHP - some libraries for doing this?

    Hi All,

    Up until now I have been storing passwords in the database as an sha1 hash.
    I like doing it this way, but a problem arises with people who forget their
    passwords - I cannot retrieve it for them.

    The simplest option would be cleartext passwords. Easy enough. But what I
    would prefer to do is some sort of two-way encryption, so I can encrypt the
    passwords, store them in the database, and then get them back. Are there
    any PHP libraries out there that can do this? I have thought about rolling
    my own, but do not want to duplicate somebody else's effort.

    A cursory look for this sort of thing returned only one-way (hashing)
    encryption techniques. This leaves me back where I was, having to reset
    users passwords, rather than emailing it back to them.

    I am not running a banking application here, so I am not too paranoid about
    security. But, it would be nice to have some reasonable level of encryption
    that is harder than rot13 to break.

    Thoughts?

    -Josh


  • Brendan Donahue

    #2
    Re: Two way encryption with PHP - some libraries for doing this?

    Joshua Beall wrote:
    [color=blue]
    > Hi All,
    >
    > Up until now I have been storing passwords in the database as an sha1
    > hash. I like doing it this way, but a problem arises with people who
    > forget their passwords - I cannot retrieve it for them.
    >
    > The simplest option would be cleartext passwords. Easy enough. But what
    > I would prefer to do is some sort of two-way encryption, so I can encrypt
    > the
    > passwords, store them in the database, and then get them back. Are there
    > any PHP libraries out there that can do this? I have thought about
    > rolling my own, but do not want to duplicate somebody else's effort.
    >
    > A cursory look for this sort of thing returned only one-way (hashing)
    > encryption techniques. This leaves me back where I was, having to reset
    > users passwords, rather than emailing it back to them.
    >
    > I am not running a banking application here, so I am not too paranoid
    > about
    > security. But, it would be nice to have some reasonable level of
    > encryption that is harder than rot13 to break.
    >
    > Thoughts?
    >
    > -Josh[/color]
    PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.

    Comment

    • Joshua Beall

      #3
      Re: Two way encryption with PHP - some libraries for doing this?

      "Brendan Donahue" <wizard@wizards ofwebsites.com> wrote in message
      news:K9-dnbGElvcrRRfd4p 2dnA@comcast.co m...[color=blue]
      > Joshua Beall wrote:[color=green]
      > > what I would prefer to do is some sort of two-way encryption[/color][/color]
      <snip>
      [color=blue]
      > http://php.net/crypt[/color]

      From the PHP manual:

      "crypt -- One-way string encryption (hashing) "

      I am looking two way encryption solutions, as I clearly stated in the OP.

      Any pointers?


      Comment

      • Tim Van Wassenhove

        #4
        Re: Two way encryption with PHP - some libraries for doing this?

        In article <_tAic.65561$L3 1.5100@nwrddc01 .gnilink.net>, Joshua Beall wrote:[color=blue]
        > Up until now I have been storing passwords in the database as an sha1 hash.
        > I like doing it this way, but a problem arises with people who forget their
        > passwords - I cannot retrieve it for them.
        >
        > The simplest option would be cleartext passwords. Easy enough.[/color]

        Imho, there is a simpler solution. Don't recover the password, but
        generate a new one for them.
        [color=blue]
        > But what I
        > would prefer to do is some sort of two-way encryption, so I can encrypt the
        > passwords, store them in the database, and then get them back. Are there
        > any PHP libraries out there that can do this? I have thought about rolling
        > my own, but do not want to duplicate somebody else's effort.[/color]

        With GnuPG / PGP you could put your public key on the server. Now write
        a script that uses that public key to encrypt the data. And whenever you
        need to decrypt the data, use your private key.

        --

        Comment

        • Cameron

          #5
          Re: Two way encryption with PHP - some libraries for doing this?

          PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.



          "Joshua Beall" <jbeall@donotsp am.remove.me.he raldic.us> wrote in message news:<_tAic.655 61$L31.5100@nwr ddc01.gnilink.n et>...[color=blue]
          > Hi All,
          >
          > Up until now I have been storing passwords in the database as an sha1 hash.
          > I like doing it this way, but a problem arises with people who forget their
          > passwords - I cannot retrieve it for them.
          >
          > The simplest option would be cleartext passwords. Easy enough. But what I
          > would prefer to do is some sort of two-way encryption, so I can encrypt the
          > passwords, store them in the database, and then get them back. Are there
          > any PHP libraries out there that can do this? I have thought about rolling
          > my own, but do not want to duplicate somebody else's effort.
          >
          > A cursory look for this sort of thing returned only one-way (hashing)
          > encryption techniques. This leaves me back where I was, having to reset
          > users passwords, rather than emailing it back to them.
          >
          > I am not running a banking application here, so I am not too paranoid about
          > security. But, it would be nice to have some reasonable level of encryption
          > that is harder than rot13 to break.
          >
          > Thoughts?
          >
          > -Josh[/color]

          Comment

          • Tony Marston

            #6
            Re: Two way encryption with PHP - some libraries for doing this?

            Take a look at http://www.tonymarston.co.uk/php-mysql/encryption.html which
            describes a reversible encryption routine for PHP. There is an online test
            harness so you can see it working, and you have access to the code as well.

            HTH.

            --
            Tony Marston

            This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL




            "Joshua Beall" <jbeall@donotsp am.remove.me.he raldic.us> wrote in message
            news:_tAic.6556 1$L31.5100@nwrd dc01.gnilink.ne t...[color=blue]
            > Hi All,
            >
            > Up until now I have been storing passwords in the database as an sha1[/color]
            hash.[color=blue]
            > I like doing it this way, but a problem arises with people who forget[/color]
            their[color=blue]
            > passwords - I cannot retrieve it for them.
            >
            > The simplest option would be cleartext passwords. Easy enough. But what[/color]
            I[color=blue]
            > would prefer to do is some sort of two-way encryption, so I can encrypt[/color]
            the[color=blue]
            > passwords, store them in the database, and then get them back. Are there
            > any PHP libraries out there that can do this? I have thought about[/color]
            rolling[color=blue]
            > my own, but do not want to duplicate somebody else's effort.
            >
            > A cursory look for this sort of thing returned only one-way (hashing)
            > encryption techniques. This leaves me back where I was, having to reset
            > users passwords, rather than emailing it back to them.
            >
            > I am not running a banking application here, so I am not too paranoid[/color]
            about[color=blue]
            > security. But, it would be nice to have some reasonable level of[/color]
            encryption[color=blue]
            > that is harder than rot13 to break.
            >
            > Thoughts?
            >
            > -Josh
            >
            >[/color]


            Comment

            • Joshua Beall

              #7
              Re: Two way encryption with PHP - some libraries for doing this?

              "Tony Marston" <tony@NOSPAM.de mon.co.uk> wrote in message
              news:c6g7a9$543 $1$8300dec7@new s.demon.co.uk.. .[color=blue]
              > Take a look at http://www.tonymarston.co.uk/php-mysql/encryption.html[/color]
              which[color=blue]
              > describes a reversible encryption routine for PHP. There is an online test
              > harness so you can see it working, and you have access to the code as[/color]
              well.

              After a cursory look, I think this is exactly the sort of thing I need.
              Thanks much!


              Comment

              • Lucas

                #8
                Re: Two way encryption with PHP - some libraries for doing this?

                Hi Joshua,

                two possible solutions:

                1) have people remember their passwords or they will have to live with
                new ones.
                2) or start up a bank. :)


                P.S. You may wanna store passwords in plaintext since you are not
                running a bank. If the database gets compromised the attacker will
                very likely not be interested in your passwords (since s/he already
                posesses system wide access)

                Best Regards,

                Lucas


                "Joshua Beall" <jbeall@donotsp am.remove.me.he raldic.us> wrote in message news:<_tAic.655 61$L31.5100@nwr ddc01.gnilink.n et>...[color=blue]
                > Hi All,
                >
                > Up until now I have been storing passwords in the database as an sha1 hash.
                > I like doing it this way, but a problem arises with people who forget their
                > passwords - I cannot retrieve it for them.
                >
                > The simplest option would be cleartext passwords. Easy enough. But what I
                > would prefer to do is some sort of two-way encryption, so I can encrypt the
                > passwords, store them in the database, and then get them back. Are there
                > any PHP libraries out there that can do this? I have thought about rolling
                > my own, but do not want to duplicate somebody else's effort.
                >
                > A cursory look for this sort of thing returned only one-way (hashing)
                > encryption techniques. This leaves me back where I was, having to reset
                > users passwords, rather than emailing it back to them.
                >
                > I am not running a banking application here, so I am not too paranoid about
                > security. But, it would be nice to have some reasonable level of encryption
                > that is harder than rot13 to break.
                >
                > Thoughts?
                >
                > -Josh[/color]

                Comment

                • Chung Leong

                  #9
                  Re: Two way encryption with PHP - some libraries for doing this?

                  "Joshua Beall" <jbeall@donotsp am.remove.me.he raldic.us> wrote in message
                  news:_tAic.6556 1$L31.5100@nwrd dc01.gnilink.ne t...[color=blue]
                  > Hi All,
                  >
                  > I am not running a banking application here, so I am not too paranoid[/color]
                  about[color=blue]
                  > security. But, it would be nice to have some reasonable level of[/color]
                  encryption[color=blue]
                  > that is harder than rot13 to break.[/color]

                  Something like this would work:

                  define(A, '0123456789ABCD EFGHIJKLMNOPQRS TUVWXYZabcdefgh ijklmnopqrstuvw xyz');
                  define(B, 'fo2gFeBMQ45Vl3 sDp1HGTYbz7vWdi kU86taqSPE0muZO j9cKrxRLnJXhwyC IAN');
                  // str_shuffle(A)

                  function lamefish($text, $decrypt = false) {
                  return $decrypt ? strtr($text, B, A) : strtr($text, A, B);
                  }

                  Should be very hard to break if the passwords are strong.


                  Comment

                  Working...