Feature Request #4026

Add option for url-safe encryption

Added by Jason Orrill 12 months ago. Updated 4 months ago.

Status:Closed Start date:05/26/2011
Priority:Normal Due date:
Assignee:Woody Gilk % Done:

0%

Category:Core
Target version:-
Resolution:invalid Points:

Description

I've got a case where I need to pass some encrypted data in the query string. However, the results of Encrypt::encode are not always URL-safe. There's a note on the user-contributed docs for base64_encode (http://us2.php.net/base64_encode) on how to implement a variant that is URL-safe. It would be handy to have that as an option for encoding/decoding data. I've extended the Encrypt class to get what I need, but since this is being passed between two separate applications there's more work in making sure that functionality is where I need it than if the core system supported it. Code sample from the above URL below:

<?php 
function base64url_encode($data) { 
  return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); 
} 

function base64url_decode($data) { 
  return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT)); 
} 
?>

History

Updated by Jeremy Bush 12 months ago

  • Target version set to v3.3.0

Updated by Chris Smith 10 months ago

Or just encode the data properly?

Updated by Jeremy Bush 5 months ago

  • Target version changed from v3.3.0 to Unscheduled

Updated by Woody Gilk 4 months ago

  • Status changed from New to Closed
  • Assignee set to Woody Gilk
  • Target version deleted (Unscheduled)
  • Resolution set to invalid

Just use rawurlencode on the encrypted string. Using URL::query or http_build_query (which URL::query uses) would automatically apply encoding.

Also available in: Atom PDF