Skip to content
Snippets Groups Projects
Commit a5a92662 authored by Martin Nilsson's avatar Martin Nilsson
Browse files

Backported encode/decode base64url

parent b688f2aa
No related branches found
No related tags found
No related merge requests found
......@@ -1615,3 +1615,17 @@ int|object reconstruct_partial(array(object) collection)
return reconstructed;
} else return (maxgot>total? -1 : total-got);
}
//! Encode strings according to @rfc{4648@} base64url encoding.
string encode_base64url(string x)
{
x = replace(encode_base64(x,1),({ "+", "/" }),({ "-", "_" }));
while( sizeof(x) && x[-1]=='=' ) x=x[..<1];
return x;
}
//! Decode strings according to @rfc{4648@} base64url encoding.
string decode_base64url(string x)
{
return decode_base64(replace(x,({ "-", "_" }),({ "+", "/" })));
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment