Security and Cryptography
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsSystem AdministrationSecurity and Cryptography

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 8th, 2008, 07:09 AM
Doctornick Doctornick is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 27 Doctornick User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 h 3 m 50 sec
Reputation Power: 0
Encoding URL variables in a PHP/C# compatible way

I've had nothing to do with encryption/encoding before, so would be grateful if anyone could point me in the direction of what I should be learning to do the following:

Using PHP, I want to encrypt a string similar to the following:
id=100477&email=roger.smith&client=544444
so that it becomes one string that can be unencrypted by an ASPX page.

Example:
A user on the company intranet enters details into a (PHP) form that would create the unencrypted URL:
www.company.com/feedbackform.aspx?id=100477&email=roger.smith&client=544444
However, the encrypted URL that it does produce looks like: www.company.com/feedbackform.aspx?var=8a0a90afjafp0a49pqje9ajf093j
or something like that...

When that link is clicked on, the aspx page uses a 'key' or similar, to unscramble the 'var' string, and extract the values of the 'id', 'email' & 'client' variables.

Any suggestions appreciated!

Reply With Quote
  #2  
Old August 8th, 2008, 10:18 AM
IamPatrick IamPatrick is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2007
Posts: 213 IamPatrick User rank is Private First Class (20 - 50 Reputation Level)IamPatrick User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 3 Days 18 h 3 m 45 sec
Reputation Power: 7
loads of ways of doing it, heres a few:

1: add x to each ascii character and send that, not secure but gibberish to the idle hacker (perhaps complicate it by adding 5 + pos of character etc etc).
2: If you trust the integrity of both ends then generate and store the same secret key on the server and all clients and use AES or similar to encrypt with said key, secure so long as no hacker can get the key
3: If you only trust the server then generate an asymmetirc key and use RSA or ECC as above (with the client side only having a public key, the server having the private key)
4: Change the design so you use https and pass the data encrypted by that

The complexity of key management make me prefer solution 1 unless you really need the system to be secure. 4 would seem to be the standard method to secure data across networks.

If you do need full encryption then c# and php have libraries to generate keys, encrypt, decrypt etc using numerous algorithms.

Reply With Quote
  #3  
Old August 13th, 2008, 11:18 AM
Doctornick Doctornick is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 27 Doctornick User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 h 3 m 50 sec
Reputation Power: 0
Quote:
Originally Posted by IamPatrick
loads of ways of doing it, heres a few:

1: add x to each ascii character and send that, not secure but gibberish to the idle hacker (perhaps complicate it by adding 5 + pos of character etc etc).
2: If you trust the integrity of both ends then generate and store the same secret key on the server and all clients and use AES or similar to encrypt with said key, secure so long as no hacker can get the key
3: If you only trust the server then generate an asymmetirc key and use RSA or ECC as above (with the client side only having a public key, the server having the private key)
4: Change the design so you use https and pass the data encrypted by that

The complexity of key management make me prefer solution 1 unless you really need the system to be secure. 4 would seem to be the standard method to secure data across networks.

If you do need full encryption then c# and php have libraries to generate keys, encrypt, decrypt etc using numerous algorithms.


Many thanks - that gives me all the options to investigate I need.

Cheers,

Nick

Reply With Quote
  #4  
Old August 13th, 2008, 12:09 PM
fishtoprecords's Avatar
fishtoprecords fishtoprecords is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Sep 2007
Location: outside Washington DC
Posts: 2,642 fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)  Folding Points: 2568392 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2568392 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2568392 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2568392 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2568392 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2568392 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2568392 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2568392 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2568392 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2568392 Folding Title: Super Ultimate Folder - Level 6
Time spent in forums: 3 Weeks 4 Days 23 h 21 m 56 sec
Reputation Power: 3682
A much cleaner approach is to not bother to "encrypt" the query string, but rather send a nonce. and on your server, keep a hash table indexed by the nonce into a structure that has all the data fields.

So don't send a URL like

Code:
www.company.com/feedbackform.aspx?id=100477&email=roger.smith&client=544444

or even

Code:
www.company.com/feedbackform.aspx?var=8a0a90afjafp0a49pqje9ajf093j


Rather call a random number generator, get a nonce, and send the URL as
Code:
www.company.com/do.aspx?nonce=12345FD123


Then just have a hashmap that converts
12345FD123 to
Code:
id=100477
email=roger.smith
client=544444


Never trust a client. So if the user/client/browser sends back the proper nonce, you are set to go. If they send a nonce that is not in your hash table, you know they are a bad guy.
Comments on this post
CyBerHigh agrees: Exactly what I would do/say!

Reply With Quote
  #5  
Old August 21st, 2008, 03:30 AM
Freewebspace Freewebspace is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2008
Location: Madurai,India
Posts: 59 Freewebspace User rank is Lance Corporal (50 - 100 Reputation Level)Freewebspace User rank is Lance Corporal (50 - 100 Reputation Level)Freewebspace User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 11 h 31 m 46 sec
Reputation Power: 5
Send a message via Google Talk to Freewebspace
Quote:
Originally Posted by fishtoprecords
d
even

Code:
www.company.com/feedbackform.aspx?var=8a0a90afjafp0a49pqje9ajf093j





The above one would be much difficult to understand right? why can't we use base64 encoding and decoding?

Reply With Quote
  #6  
Old August 21st, 2008, 11:08 AM
fishtoprecords's Avatar
fishtoprecords fishtoprecords is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Sep 2007
Location: outside Washington DC
Posts: 2,642 fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)fishtoprecords User rank is General 41st Grade (Above 100000 Reputation Level)  Folding Points: 2568392 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2568392 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2568392 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2568392 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2568392 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2568392 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2568392 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2568392 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2568392 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2568392 Folding Title: Super Ultimate Folder - Level 6
Time spent in forums: 3 Weeks 4 Days 23 h 21 m 56 sec
Reputation Power: 3682
Its not difficult to understand.

It is not at all "the same" as base64 encoding. And if security is a concern, base64 encoding is not a cipher.

The rule is never to trust what you get from the client. Might be a browser, might be a rogue program claiming to be a browser.

With the nonce/hash approach, if the rogue studies it, they learn it is a random number. If they change it, we don't find the entry in the hashmap and know instantly that they are bad guys.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationSecurity and Cryptography > Encoding URL variables in a PHP/C# compatible way

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap