Forum Discussion
NetSnoopy
Cirrus
Apr 13, 2017Base64 ( b64encode) vs Base64Url Encode and Base64UrlDecode
Hello all,
The last days i had a lot of problems to build a iRule that contains strings with Base64UrlEncode. URLencode means replace "+" to "-" and "/" to "_" and cut trailing "=".
- URI::encode is not URL encode
- first do a b64encode
- replace string with "[string map [list + - \/ _ = "" ] $var]"
In a Irule shows like:
set var_b64_url "[string map [list + - \/ _ = "" ] [b64encode "$var"]"
But i do not have a solution to do this revers for Base64UrlDecode
my idea is
set var_b64 "[string map [list - + _ \/ ] $var_b64_url"]"
set var_decode "[b64decode $var_b64]"
But i don't have a solution for the trailing "=" ?
Cheers, NetSnoopy
- cjunior
Nacreous
Hi, it is an interesting your request, so I'll not ask what you are intending and just try a statement.
set var_b64 "[string map [list - + _ \/ ] $var_b64_url]" if { [string length $var_b64] % 4 != 0 } { append var_b64 [string repeat = [expr {4 - [string length $var_b64] % 4}]] }
I hope it helps you.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects