First commit
This commit is contained in:
@@ -0,0 +1,158 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="writer-html5" lang="en" >
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="shortcut icon" href="../img/favicon.ico" />
|
||||
<title>Generating RSA Keys - CryptoTools documentation</title>
|
||||
<link rel="stylesheet" href="../css/theme.css" />
|
||||
<link rel="stylesheet" href="../css/theme_extra.css" />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/github.min.css" />
|
||||
<link href="../assets/_mkdocstrings.css" rel="stylesheet" />
|
||||
|
||||
<script>
|
||||
// Current page data
|
||||
var mkdocs_page_name = "Generating RSA Keys";
|
||||
var mkdocs_page_input_path = "examples-rsa-keys.md";
|
||||
var mkdocs_page_url = null;
|
||||
</script>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="../js/html5shiv.min.js"></script>
|
||||
<![endif]-->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
|
||||
<script>hljs.highlightAll();</script>
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav" role="document">
|
||||
|
||||
<div class="wy-grid-for-nav">
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search">
|
||||
<a href=".." class="icon icon-home"> CryptoTools documentation
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../introduction/">Introduction</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../installation/">Installation</a>
|
||||
</li>
|
||||
</ul>
|
||||
<p class="caption"><span class="caption-text">Low-level cryptographic</span></p>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../number-theory/">Number theory</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../group-theory/">Group theory</a>
|
||||
</li>
|
||||
</ul>
|
||||
<p class="caption"><span class="caption-text">Public Keys</span></p>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../rsa/">RSA</a>
|
||||
</li>
|
||||
</ul>
|
||||
<p class="caption"><span class="caption-text">Examples</span></p>
|
||||
<ul class="current">
|
||||
<li class="toctree-l1 current"><a class="reference internal current" href="#">Generating RSA Keys</a>
|
||||
<ul class="current">
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||
<nav class="wy-nav-top" role="navigation" aria-label="Mobile navigation menu">
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="..">CryptoTools documentation</a>
|
||||
|
||||
</nav>
|
||||
<div class="wy-nav-content">
|
||||
<div class="rst-content"><div role="navigation" aria-label="breadcrumbs navigation">
|
||||
<ul class="wy-breadcrumbs">
|
||||
<li><a href=".." class="icon icon-home" aria-label="Docs"></a></li>
|
||||
<li class="breadcrumb-item">Examples</li>
|
||||
<li class="breadcrumb-item active">Generating RSA Keys</li>
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
</li>
|
||||
</ul>
|
||||
<hr/>
|
||||
</div>
|
||||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||||
<div class="section" itemprop="articleBody">
|
||||
|
||||
<h1 id="generating-rsa-keys">Generating RSA Keys</h1>
|
||||
<p>In the following section, we are going to see how to generate RSA Keys and how to encrypt data with these keys.</p>
|
||||
<pre><code>#!/usr/bin/env python3
|
||||
|
||||
from Cryptotools.Encryptions.RSA import RSA
|
||||
|
||||
|
||||
rsa = RSA()
|
||||
rsa.generateKeys(size=512)
|
||||
|
||||
e = rsa.e
|
||||
d = rsa.d
|
||||
n = rsa.n
|
||||
|
||||
s = "I am encrypted with RSA"
|
||||
print(f"plaintext: {s}")
|
||||
encrypted = rsa.encrypt(s)
|
||||
|
||||
# Encrypt data
|
||||
print(f"ciphertext: {encrypted}")
|
||||
|
||||
# We decrypt
|
||||
plaintext = rsa.decrypt(encrypted)
|
||||
print(f"Plaintext: {plaintext}")
|
||||
</code></pre>
|
||||
|
||||
</div>
|
||||
</div><footer>
|
||||
<div class="rst-footer-buttons" role="navigation" aria-label="Footer Navigation">
|
||||
<a href="../rsa/" class="btn btn-neutral float-left" title="RSA"><span class="icon icon-circle-arrow-left"></span> Previous</a>
|
||||
</div>
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<!-- Copyright etc -->
|
||||
</div>
|
||||
|
||||
Built with <a href="https://www.mkdocs.org/">MkDocs</a> using a <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="rst-versions" role="note" aria-label="Versions">
|
||||
<span class="rst-current-version" data-toggle="rst-current-version">
|
||||
|
||||
|
||||
<span><a href="../rsa/" style="color: #fcfcfc">« Previous</a></span>
|
||||
|
||||
|
||||
</span>
|
||||
</div>
|
||||
<script src="../js/jquery-3.6.0.min.js"></script>
|
||||
<script>var base_url = "..";</script>
|
||||
<script src="../js/theme_extra.js"></script>
|
||||
<script src="../js/theme.js"></script>
|
||||
<script>
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user