matt
matt

Reputation: 44353

secure way to deliver password over URL?

i wonder if there's a secure way to deliver a password with an URL (like ?p=mypassword) how can i encrypt and decrypt such a password so it's secure.

i guess md5 is not working in my case because the password must still be readable. It's an FTP passwort which gets passes along to the ftp_connect. i think md5 doesn't work in this case because i have to query if a string matches the md5 hash. however i can't do that in my case.

any ideas?

Upvotes: 2

Views: 2626

Answers (3)

Pasta
Pasta

Reputation: 2491

Instead of using a one way hash (MD5, SHA1). I think you need an encrypt-decrypt function. Take a look at this http://www.php.net/manual/en/function.mcrypt-encrypt.php.

The above example, you can encrypt using the key and pass the password in the URL. Once the password is received by PHP, you can then decrypt the password and use it to connect FTP. The only limitation is that the key will have to be available on the PHP server and wherever you generate the URL. There are also limits on the size of the string but I think you will be within those limits generally.

Upvotes: 0

Aiden Bell
Aiden Bell

Reputation: 28384

Erm: Send via POST + SSL

SSL ensures that the password can not easily be read by third parties while in transit. Sending it via POST simply sends the variable to the server outside the URL and keeps it out of the server logs (hopefully). This will do an alright job hiding it from browser history or people sniffing HTTP.

But then, doesn't ftp_login() send this plaintext when using ftp_connect() making a mockery of the SSL in HTTP? Make sure you use ftp_ssl_connect() to your server afterwards. See the ftp_ssl_connect() PHP manual entry

Upvotes: 6

ceejayoz
ceejayoz

Reputation: 180065

If your site accepts an encrypted password in the query string, that encrypted string - though unreadable - is functionally no different than the password itself.

If my password to enter the CIA is "password", but they'll let me in if I say "5f4dcc3b5aa765d61d8327deb882cf99", both strings function as my password and both need to be protected.

Upvotes: 2

Related Questions