跳转到主要内容

url64 decode/encode for python

项目描述

url64
🐍 base64url decode/encode for python

Build Status coverage PyPI



💾 安装 🎮 快速入门 🌐 链接 👤 贡献 💼 许可证

url64RFC4648 §5中描述的 base64url 的常用名称。由于原始base64字母表包含对URL无效的字符,建议使用安全的base64进行url编码,将第62个(加号 +)和第63个(斜杠 /)字符分别替换为新字符减号 - 和下划线 _,并移除也表示为等号 = 的填充。

这是一个方便的小工具,用于使用python3对url64字符串进行编码/解码,非常适用于JWT。

🚩 目录(点击展开)

💾 安装

pip安装url64


🎮 快速入门

编码

import url64

encoded = url64.encode('Hello world!')
print(encoded)  # SGVsbG8gd29ybGQh

dict_exncode = url64.encode(dict(alg="HS256", typ="JWT"))
print(dict_exncode) # eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9

解码

import url64

decoded = url64.decode('SGVsbG8gd29ybGQh')
print(decoded)  # Hello world!

dict_decoded = url64.decode('eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9')
print(dict_decoded) # {"alg": "HS256", "typ": "JWT"}

🌐 链接

https://tools.ietf.org/html/rfc4648#section-5

https://en.wikipedia.org/wiki/Base64#URL_applications

https://base64.guru/standards/base64url


👤 贡献

  1. 🔀 FORK IT
  2. 创建您的功能分支 git checkout -b feature/branch
  3. 提交您的更改 git commit -am '添加一些fooBar'
  4. 推送到分支 git push origin feature/branch
  5. 创建新的拉取请求
  6. 🙏 感谢

💼 许可证

Copyright (c) 2019 Puria Nafisi Azizi

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://apache.ac.cn/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

项目详情


下载文件

下载适用于您平台文件的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源代码分发

url64-0.1.0.tar.gz (7.1 kB 查看哈希值)

上传时间 源代码

构建分发

url64-0.1.0-py2.py3-none-any.whl (7.5 kB 查看哈希值)

上传时间 Python 2 Python 3

由以下支持