Help us understand the problem. What is going on with this article?

base64url をデコードする

More than 1 year has passed since last update.

base64url をデコードする

OpenID Connect に関わるたびに、ID トークンをデコードするために書いてる気がしたので. そもそも Python がパディング無しに対応するオプションを付けてくれればいいのにな…….

import base64

def decode_base64url(s):
  return base64.urlsafe_b64decode(s + b'=' * ((4 - len(s) & 3) & 3))

def encode_base64url(s):
  return base64.urlsafe_b64encode(s).rstrip(b'=')
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away