Skip to content

Instantly share code, notes, and snippets.

@zema1
Last active July 20, 2018 06:47
Show Gist options
  • Save zema1/f050784ebbc90231c60e6b9ece9eb9cd to your computer and use it in GitHub Desktop.
Save zema1/f050784ebbc90231c60e6b9ece9eb9cd to your computer and use it in GitHub Desktop.

Revisions

  1. zema1 renamed this gist Jul 20, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. zema1 created this gist Jul 20, 2018.
    16 changes: 16 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    ```
    def base64_url_encode(text):
    return base64.b64encode(text).replace('+', '-').replace('/', '_').replace('=', '')


    def base64_url_decode(text):
    text = text.replace('-', '+').replace('_', '/')
    while True:
    try:
    result = base64.b64decode(text)
    except TypeError:
    text += '='
    else:
    break
    return result
    ```