bcp1 0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bcp1-0.1/MANIFEST.in +1 -0
- bcp1-0.1/PKG-INFO +3 -0
- bcp1-0.1/README.md +5 -0
- bcp1-0.1/bcp1/__init__.py +2 -0
- bcp1-0.1/bcp1/data.txt +46 -0
- bcp1-0.1/bcp1.egg-info/PKG-INFO +3 -0
- bcp1-0.1/bcp1.egg-info/SOURCES.txt +10 -0
- bcp1-0.1/bcp1.egg-info/dependency_links.txt +1 -0
- bcp1-0.1/bcp1.egg-info/top_level.txt +1 -0
- bcp1-0.1/pyproject.toml +3 -0
- bcp1-0.1/setup.cfg +4 -0
- bcp1-0.1/setup.py +9 -0
bcp1-0.1/MANIFEST.in
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include bcp1/data.txt
|
bcp1-0.1/PKG-INFO
ADDED
bcp1-0.1/README.md
ADDED
bcp1-0.1/bcp1/data.txt
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from cryptography.hazmat.primitives.asymmetric import rsa, padding
|
|
2
|
+
from cryptography.hazmat.primitives import hashes, serialization
|
|
3
|
+
|
|
4
|
+
# Generate keys
|
|
5
|
+
private_key = rsa.generate_private_key(
|
|
6
|
+
public_exponent=65537,
|
|
7
|
+
key_size=2048
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
public_key = private_key.public_key()
|
|
11
|
+
|
|
12
|
+
# Message
|
|
13
|
+
message = b"Hello, this is a digital message."
|
|
14
|
+
|
|
15
|
+
# Sign the message
|
|
16
|
+
signature = private_key.sign(
|
|
17
|
+
message,
|
|
18
|
+
padding.PKCS1v15(),
|
|
19
|
+
hashes.SHA256()
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
print("Signature created successfully.")
|
|
23
|
+
|
|
24
|
+
# Verify the signature
|
|
25
|
+
try:
|
|
26
|
+
public_key.verify(
|
|
27
|
+
signature,
|
|
28
|
+
message,
|
|
29
|
+
padding.PKCS1v15(),
|
|
30
|
+
hashes.SHA256()
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
print("Signature Verified Successfully.")
|
|
34
|
+
|
|
35
|
+
except:
|
|
36
|
+
print("Signature verification failed.")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# Convert public key into PEM format
|
|
40
|
+
public_pem = public_key.public_bytes(
|
|
41
|
+
encoding=serialization.Encoding.PEM,
|
|
42
|
+
format=serialization.PublicFormat.SubjectPublicKeyInfo
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
print("\nPublic key:")
|
|
46
|
+
print(public_pem.decode())
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bcp1
|
bcp1-0.1/pyproject.toml
ADDED
bcp1-0.1/setup.cfg
ADDED