Skip to content

Instantly share code, notes, and snippets.

@wirekang
Created November 13, 2023 01:46
Show Gist options
  • Save wirekang/f48a15e1b21be51f8d2741a904a38813 to your computer and use it in GitHub Desktop.
Save wirekang/f48a15e1b21be51f8d2741a904a38813 to your computer and use it in GitHub Desktop.
Postgres web-safe base64 encode
create or replace function "base64_url"(bytea) returns text as
$$
select replace(replace(replace(encode($1, 'base64'),'/','_'),'+','-'),'=','');
$$
language sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment