Skip to content

Commit

Permalink
deploy: a4ee11f
Browse files Browse the repository at this point in the history
  • Loading branch information
baniasbaabe committed Jun 14, 2024
1 parent 121ed95 commit eb7f88a
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
38 changes: 37 additions & 1 deletion _sources/book/cooltools/Chapter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2085,6 +2085,42 @@
"\n",
"predictions = run_ocr([image], [langs], det_model, det_processor, rec_model, rec_processor)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Decode/Encode JWTs with `PyJWT`"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For working with JWT in Python, use `PyJWT`.\n",
"\n",
"`PyJWT` is a Python library for encoding/decoding JWTs easily."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!pip install pyjwt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import jwt\n",
"encoded_jwt = jwt.encode({\"some\": \"payload\"}, \"secret\", algorithm=\"HS256\")\n",
"jwt.decode(encoded_jwt, \"secret\", algorithms=[\"HS256\"])"
]
}
],
"metadata": {
Expand All @@ -2095,7 +2131,7 @@
},
"language_info": {
"name": "python",
"version": "3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]"
"version": "3.9.18"
},
"orig_nbformat": 4,
"vscode": {
Expand Down
23 changes: 23 additions & 0 deletions book/cooltools/Chapter.html
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ <h2> Contents </h2>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#create-beautiful-tables-with-great-tables">2.1.40. Create Beautiful Tables with <code class="docutils literal notranslate"><span class="pre">great_tables</span></code></a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#data-quality-checks-for-dataframes-with-cuallee">2.1.41. Data Quality Checks for Dataframes with <code class="docutils literal notranslate"><span class="pre">cuallee</span></code></a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#ocr-line-detection-and-layout-analysis-with-surya">2.1.42. OCR, Line Detection and Layout Analysis with <code class="docutils literal notranslate"><span class="pre">surya</span></code></a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#decode-encode-jwts-with-pyjwt">2.1.43. Decode/Encode JWTs with <code class="docutils literal notranslate"><span class="pre">PyJWT</span></code></a></li>
</ul>
</nav>
</div>
Expand Down Expand Up @@ -1758,6 +1759,27 @@ <h2><span class="section-number">2.1.42. </span>OCR, Line Detection and Layout A
</div>
</div>
</section>
<section id="decode-encode-jwts-with-pyjwt">
<h2><span class="section-number">2.1.43. </span>Decode/Encode JWTs with <code class="docutils literal notranslate"><span class="pre">PyJWT</span></code><a class="headerlink" href="#decode-encode-jwts-with-pyjwt" title="Permalink to this heading">#</a></h2>
<p>For working with JWT in Python, use <code class="docutils literal notranslate"><span class="pre">PyJWT</span></code>.</p>
<p><code class="docutils literal notranslate"><span class="pre">PyJWT</span></code> is a Python library for encoding/decoding JWTs easily.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span>!pip install pyjwt
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">jwt</span>
<span class="n">encoded_jwt</span> <span class="o">=</span> <span class="n">jwt</span><span class="o">.</span><span class="n">encode</span><span class="p">({</span><span class="s2">&quot;some&quot;</span><span class="p">:</span> <span class="s2">&quot;payload&quot;</span><span class="p">},</span> <span class="s2">&quot;secret&quot;</span><span class="p">,</span> <span class="n">algorithm</span><span class="o">=</span><span class="s2">&quot;HS256&quot;</span><span class="p">)</span>
<span class="n">jwt</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="n">encoded_jwt</span><span class="p">,</span> <span class="s2">&quot;secret&quot;</span><span class="p">,</span> <span class="n">algorithms</span><span class="o">=</span><span class="p">[</span><span class="s2">&quot;HS256&quot;</span><span class="p">])</span>
</pre></div>
</div>
</div>
</div>
</section>
</section>

<script type="text/x-thebe-config">
Expand Down Expand Up @@ -1869,6 +1891,7 @@ <h2><span class="section-number">2.1.42. </span>OCR, Line Detection and Layout A
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#create-beautiful-tables-with-great-tables">2.1.40. Create Beautiful Tables with <code class="docutils literal notranslate"><span class="pre">great_tables</span></code></a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#data-quality-checks-for-dataframes-with-cuallee">2.1.41. Data Quality Checks for Dataframes with <code class="docutils literal notranslate"><span class="pre">cuallee</span></code></a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#ocr-line-detection-and-layout-analysis-with-surya">2.1.42. OCR, Line Detection and Layout Analysis with <code class="docutils literal notranslate"><span class="pre">surya</span></code></a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#decode-encode-jwts-with-pyjwt">2.1.43. Decode/Encode JWTs with <code class="docutils literal notranslate"><span class="pre">PyJWT</span></code></a></li>
</ul>
</nav></div>

Expand Down
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

0 comments on commit eb7f88a

Please sign in to comment.