juneja-codebase 2.4.0__tar.gz → 4.1.0__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.
- juneja_codebase-4.1.0/PKG-INFO +60 -0
- juneja_codebase-4.1.0/README.md +42 -0
- juneja_codebase-4.1.0/juneja_codebase/__init__.py +6 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/main.py +51 -24
- juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise1_Blockchain +0 -0
- juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise1_Blockchain.cpp +82 -0
- juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise2_Blockchain +0 -0
- juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise2_Blockchain.cpp +69 -0
- juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise3-1_Blockchain +0 -0
- juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise3-1_Blockchain.cpp +31 -0
- juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise3-2_Blockchain +0 -0
- juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise3-2_Blockchain.cpp +23 -0
- juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise3-3_Blockchain +0 -0
- juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise3-3_Blockchain.cpp +32 -0
- juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise4_Blockchain +0 -0
- juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise4_Blockchain.cpp +25 -0
- juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise5_Blockchain +0 -0
- juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise5_Blockchain.cpp +62 -0
- juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise6_Blockchain +0 -0
- juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise6_Blockchain.cpp +91 -0
- juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise7_Blockchain +0 -0
- juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise7_Blockchain.cpp +139 -0
- juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise8-1_Blockchain.sol +15 -0
- juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise8-2_Blockchain.sol +19 -0
- juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise8-3_Blockchain.sol +21 -0
- juneja_codebase-4.1.0/juneja_codebase.egg-info/PKG-INFO +60 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase.egg-info/SOURCES.txt +21 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/setup.cfg +1 -1
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/setup.py +1 -1
- juneja_codebase-2.4.0/PKG-INFO +0 -18
- juneja_codebase-2.4.0/README.md +0 -0
- juneja_codebase-2.4.0/juneja_codebase/__init__.py +0 -6
- juneja_codebase-2.4.0/juneja_codebase.egg-info/PKG-INFO +0 -18
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/LICENSE +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/MANIFEST.in +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/compiler_design/AnshJuneja_Practical10_CD.l +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/compiler_design/AnshJuneja_Practical10_CD.y +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/compiler_design/AnshJuneja_Practical11_CD.l +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/compiler_design/AnshJuneja_Practical11_CD.y +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/compiler_design/AnshJuneja_Practical12_CD.l +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/compiler_design/AnshJuneja_Practical12_CD.y +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/compiler_design/AnshJuneja_Practical13_CD.l +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/compiler_design/AnshJuneja_Practical13_CD.y +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/compiler_design/AnshJuneja_Practical1_CD.l +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/compiler_design/AnshJuneja_Practical2_CD.l +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/compiler_design/AnshJuneja_Practical3_CD.l +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/compiler_design/AnshJuneja_Practical4_CD.l +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/compiler_design/AnshJuneja_Practical5_CD.l +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/compiler_design/AnshJuneja_Practical6_CD.l +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/compiler_design/AnshJuneja_Practical7_CD.l +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/compiler_design/AnshJuneja_Practical8_CD.l +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/compiler_design/AnshJuneja_Practical9_CD.l +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/compiler_design/AnshJuneja_Practical9_CD.y +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/deep_learning/Denoised_Autoencoders.ipynb +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/deep_learning/Fashion_Mnist_DenseNet201_VGG19_PreTModel.ipynb +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/deep_learning/Image_Compression_Autoencoders.ipynb +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/deep_learning/boston_housing.ipynb +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/deep_learning/cnn_fashionmnist.ipynb +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/deep_learning/posneg_imdb_ffnn..ipynb +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/deep_learning/reuters.ipynb +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/deep_learning/rnnlstm_timeseries_imdb.ipynb +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/social_network_analysis/1_try.ipynb +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/social_network_analysis/2_try.ipynb +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/social_network_analysis/3_try.ipynb +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/social_network_analysis/4_try.ipynb +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/social_network_analysis/5_try.ipynb +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/social_network_analysis/6_try.ipynb +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase/templates/social_network_analysis/new.ipynb +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase.egg-info/dependency_links.txt +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase.egg-info/entry_points.txt +0 -0
- {juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: juneja_codebase
|
|
3
|
+
Version: 4.1.0
|
|
4
|
+
Summary: CLI tool to generate academic practical code files for Compiler Design, Data Structures, OS, and DBMS
|
|
5
|
+
Home-page: UNKNOWN
|
|
6
|
+
Author: AJ
|
|
7
|
+
License: UNKNOWN
|
|
8
|
+
Platform: UNKNOWN
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Intended Audience :: Education
|
|
13
|
+
Requires-Python: >=3.6
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
|
|
17
|
+
# juneja-codebase
|
|
18
|
+
|
|
19
|
+
Offline CLI for generating practical code files for multiple subjects.
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install juneja-codebase==4.1.0
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Use
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
juneja-codebase --list
|
|
31
|
+
juneja-codebase --all
|
|
32
|
+
juneja-codebase --subject compiler_design
|
|
33
|
+
juneja-codebase --subject blockchain
|
|
34
|
+
juneja-codebase --all --zip
|
|
35
|
+
juneja-codebase --all --output ./my_codes
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
If the console script is not on PATH, use:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
python3 -m juneja_codebase.main --list
|
|
42
|
+
python3 -m juneja_codebase.main --all
|
|
43
|
+
python3 -m juneja_codebase.main --subject blockchain
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Subjects
|
|
47
|
+
|
|
48
|
+
- Compiler Design
|
|
49
|
+
- Blockchain Codes
|
|
50
|
+
- Deep Learning
|
|
51
|
+
- Social Network Analysis
|
|
52
|
+
|
|
53
|
+
## Notes
|
|
54
|
+
|
|
55
|
+
- `--subject blockchain` resolves to the `Blockchain Codes` templates folder.
|
|
56
|
+
- The package works offline because templates ship inside the wheel and sdist.
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# juneja-codebase
|
|
2
|
+
|
|
3
|
+
Offline CLI for generating practical code files for multiple subjects.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install juneja-codebase==4.1.0
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Use
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
juneja-codebase --list
|
|
15
|
+
juneja-codebase --all
|
|
16
|
+
juneja-codebase --subject compiler_design
|
|
17
|
+
juneja-codebase --subject blockchain
|
|
18
|
+
juneja-codebase --all --zip
|
|
19
|
+
juneja-codebase --all --output ./my_codes
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
If the console script is not on PATH, use:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
python3 -m juneja_codebase.main --list
|
|
26
|
+
python3 -m juneja_codebase.main --all
|
|
27
|
+
python3 -m juneja_codebase.main --subject blockchain
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Subjects
|
|
31
|
+
|
|
32
|
+
- Compiler Design
|
|
33
|
+
- Blockchain Codes
|
|
34
|
+
- Deep Learning
|
|
35
|
+
- Social Network Analysis
|
|
36
|
+
|
|
37
|
+
## Notes
|
|
38
|
+
|
|
39
|
+
- `--subject blockchain` resolves to the `Blockchain Codes` templates folder.
|
|
40
|
+
- The package works offline because templates ship inside the wheel and sdist.
|
|
41
|
+
|
|
42
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
"""
|
|
3
|
-
Main CLI entry point for
|
|
3
|
+
Main CLI entry point for juneja-codebase
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
6
|
import argparse
|
|
@@ -15,24 +15,49 @@ def get_templates_dir():
|
|
|
15
15
|
return Path(__file__).parent / "templates"
|
|
16
16
|
|
|
17
17
|
|
|
18
|
+
def normalize_subject_name(name):
|
|
19
|
+
"""Normalize a subject name for flexible matching."""
|
|
20
|
+
return "".join(ch.lower() for ch in name if ch.isalnum())
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def resolve_subject_dir(subject):
|
|
24
|
+
"""Resolve a user-supplied subject name to a template directory."""
|
|
25
|
+
templates_dir = get_templates_dir()
|
|
26
|
+
subject_lookup = normalize_subject_name(subject)
|
|
27
|
+
|
|
28
|
+
for candidate in templates_dir.iterdir():
|
|
29
|
+
if not candidate.is_dir():
|
|
30
|
+
continue
|
|
31
|
+
|
|
32
|
+
candidate_lookup = normalize_subject_name(candidate.name)
|
|
33
|
+
if (
|
|
34
|
+
candidate.name.lower() == subject.lower()
|
|
35
|
+
or candidate_lookup == subject_lookup
|
|
36
|
+
or candidate_lookup.startswith(subject_lookup)
|
|
37
|
+
or subject_lookup.startswith(candidate_lookup)
|
|
38
|
+
):
|
|
39
|
+
return candidate
|
|
40
|
+
|
|
41
|
+
return None
|
|
42
|
+
|
|
43
|
+
|
|
18
44
|
def list_subjects():
|
|
19
45
|
"""List all available subjects"""
|
|
20
46
|
templates_dir = get_templates_dir()
|
|
21
|
-
subjects =
|
|
47
|
+
subjects = sorted(d.name for d in templates_dir.iterdir() if d.is_dir())
|
|
22
48
|
return subjects
|
|
23
49
|
|
|
24
50
|
|
|
25
51
|
def copy_subject_files(subject, output_dir):
|
|
26
52
|
"""Copy files for a specific subject to the output directory"""
|
|
27
|
-
|
|
28
|
-
subject_dir = templates_dir / subject
|
|
53
|
+
subject_dir = resolve_subject_dir(subject)
|
|
29
54
|
|
|
30
|
-
if
|
|
55
|
+
if subject_dir is None:
|
|
31
56
|
print(f"Error: Subject '{subject}' not found!")
|
|
32
57
|
print(f"Available subjects: {', '.join(list_subjects())}")
|
|
33
58
|
return False
|
|
34
59
|
|
|
35
|
-
output_path = Path(output_dir) /
|
|
60
|
+
output_path = Path(output_dir) / subject_dir.name
|
|
36
61
|
output_path.mkdir(parents=True, exist_ok=True)
|
|
37
62
|
|
|
38
63
|
# Copy all files from subject directory
|
|
@@ -66,17 +91,17 @@ def create_zip_archive(subject, output_file):
|
|
|
66
91
|
|
|
67
92
|
if subject:
|
|
68
93
|
# Zip specific subject
|
|
69
|
-
subject_dir =
|
|
70
|
-
if
|
|
94
|
+
subject_dir = resolve_subject_dir(subject)
|
|
95
|
+
if subject_dir is None:
|
|
71
96
|
print(f"Error: Subject '{subject}' not found!")
|
|
72
97
|
return False
|
|
73
98
|
|
|
74
|
-
zip_name = output_file if output_file else f"{
|
|
99
|
+
zip_name = output_file if output_file else f"{subject_dir.name.replace(' ', '_')}.zip"
|
|
75
100
|
|
|
76
101
|
with zipfile.ZipFile(zip_name, 'w', zipfile.ZIP_DEFLATED) as zipf:
|
|
77
102
|
for item in subject_dir.rglob('*'):
|
|
78
103
|
if item.is_file():
|
|
79
|
-
arcname =
|
|
104
|
+
arcname = Path(subject_dir.name) / item.relative_to(subject_dir)
|
|
80
105
|
zipf.write(item, arcname)
|
|
81
106
|
print(f"Added to zip: {arcname}")
|
|
82
107
|
|
|
@@ -107,12 +132,12 @@ def main():
|
|
|
107
132
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
108
133
|
epilog="""
|
|
109
134
|
Examples:
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
135
|
+
juneja-codebase --list # List available subjects
|
|
136
|
+
juneja-codebase --all # Generate all code files
|
|
137
|
+
juneja-codebase --subject compiler_design # Generate specific subject files
|
|
138
|
+
juneja-codebase --all --output ./my_codes # Generate to specific directory
|
|
139
|
+
juneja-codebase --all --zip # Create zip of all subjects
|
|
140
|
+
juneja-codebase --subject compiler_design --zip # Create zip of specific subject
|
|
116
141
|
"""
|
|
117
142
|
)
|
|
118
143
|
|
|
@@ -150,7 +175,7 @@ Examples:
|
|
|
150
175
|
parser.add_argument(
|
|
151
176
|
'--version', '-v',
|
|
152
177
|
action='version',
|
|
153
|
-
version='%(prog)s 0.
|
|
178
|
+
version='%(prog)s 4.0.0'
|
|
154
179
|
)
|
|
155
180
|
|
|
156
181
|
args = parser.parse_args()
|
|
@@ -177,19 +202,21 @@ Examples:
|
|
|
177
202
|
# Generate files
|
|
178
203
|
if args.all:
|
|
179
204
|
print("Generating all subject files...")
|
|
180
|
-
copy_all_subjects(args.output)
|
|
181
|
-
|
|
205
|
+
if copy_all_subjects(args.output):
|
|
206
|
+
print(f"\n✓ All files generated in: {os.path.abspath(args.output)}")
|
|
207
|
+
else:
|
|
208
|
+
print("\nSome subjects could not be generated.")
|
|
182
209
|
elif args.subject:
|
|
183
210
|
print(f"Generating {args.subject} files...")
|
|
184
|
-
copy_subject_files(args.subject, args.output)
|
|
185
|
-
|
|
211
|
+
if copy_subject_files(args.subject, args.output):
|
|
212
|
+
print(f"\n✓ Files generated in: {os.path.abspath(args.output)}")
|
|
186
213
|
else:
|
|
187
214
|
# No action specified, show help
|
|
188
215
|
parser.print_help()
|
|
189
216
|
print("\n" + "="*70)
|
|
190
|
-
print("💡 TIP: If '
|
|
191
|
-
print(" python -m
|
|
192
|
-
print(" python -m
|
|
217
|
+
print("💡 TIP: If 'juneja-codebase' command doesn't work in your system, use:")
|
|
218
|
+
print(" python -m juneja_codebase.main --list")
|
|
219
|
+
print(" python -m juneja_codebase.main --all")
|
|
193
220
|
print("="*70)
|
|
194
221
|
|
|
195
222
|
|
juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise1_Blockchain
ADDED
|
Binary file
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#include <iostream>
|
|
2
|
+
#include <vector>
|
|
3
|
+
#include <string>
|
|
4
|
+
#include <iomanip>
|
|
5
|
+
#include <openssl/evp.h>
|
|
6
|
+
#include <openssl/rsa.h>
|
|
7
|
+
#include <openssl/pem.h>
|
|
8
|
+
#include <openssl/err.h>
|
|
9
|
+
|
|
10
|
+
void printHex(const unsigned char* data, size_t len) {
|
|
11
|
+
for (size_t i = 0; i < len; ++i) {
|
|
12
|
+
std::printf("%02x", data[i]);
|
|
13
|
+
if ((i + 1) % 32 == 0) std::printf("\n");
|
|
14
|
+
}
|
|
15
|
+
std::printf("\n");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
int main() {
|
|
19
|
+
std::string document = "This is a confidential document for verification.";
|
|
20
|
+
unsigned char* signature = nullptr;
|
|
21
|
+
size_t sig_len = 0;
|
|
22
|
+
|
|
23
|
+
// Generating RSA Key Pair
|
|
24
|
+
EVP_PKEY *pkey = EVP_RSA_gen(2048);
|
|
25
|
+
if (!pkey) { std::cerr << "Keygen failed\n"; return 1; }
|
|
26
|
+
|
|
27
|
+
// Printing the Private Key (The Secret Part)
|
|
28
|
+
std::cout << "\nSENDER'S PRIVATE KEY (Used for Signing):\n\n";
|
|
29
|
+
BIO* pri_bio = BIO_new(BIO_s_mem());
|
|
30
|
+
PEM_write_bio_PrivateKey(pri_bio, pkey, NULL, NULL, 0, NULL, NULL);
|
|
31
|
+
char* pri_buf;
|
|
32
|
+
size_t pri_len = BIO_get_mem_data(pri_bio, &pri_buf);
|
|
33
|
+
std::cout.write(pri_buf, pri_len) << "\n";
|
|
34
|
+
|
|
35
|
+
// Printing the Public Key (The Shared Part)
|
|
36
|
+
std::cout << "\nSENDER'S PUBLIC KEY (Shared with Receiver):\n\n";
|
|
37
|
+
BIO* pub_bio = BIO_new(BIO_s_mem());
|
|
38
|
+
PEM_write_bio_PUBKEY(pub_bio, pkey);
|
|
39
|
+
char* pub_buf;
|
|
40
|
+
size_t pub_len = BIO_get_mem_data(pub_bio, &pub_buf);
|
|
41
|
+
std::cout.write(pub_buf, pub_len) << "\n";
|
|
42
|
+
|
|
43
|
+
// Creating the Signature (Signing Process)
|
|
44
|
+
std::cout << "SIGNING THE DOCUMENT...\n";
|
|
45
|
+
std::cout << "Document Content: \"" << document << "\"\n\n";
|
|
46
|
+
|
|
47
|
+
EVP_MD_CTX *m_ctx = EVP_MD_CTX_new();
|
|
48
|
+
EVP_DigestSignInit(m_ctx, NULL, EVP_sha256(), NULL, pkey);
|
|
49
|
+
EVP_DigestSignUpdate(m_ctx, document.c_str(), document.length());
|
|
50
|
+
|
|
51
|
+
// Getting signature length first
|
|
52
|
+
EVP_DigestSignFinal(m_ctx, NULL, &sig_len);
|
|
53
|
+
signature = (unsigned char*)OPENSSL_malloc(sig_len);
|
|
54
|
+
EVP_DigestSignFinal(m_ctx, signature, &sig_len);
|
|
55
|
+
|
|
56
|
+
std::cout << "\nGENERATED SIGNATURE (HEXADECIMAL):\n\n";
|
|
57
|
+
printHex(signature, sig_len);
|
|
58
|
+
|
|
59
|
+
// Verification Process
|
|
60
|
+
std::cout << "\nVERIFYING SIGNATURE WITH PUBLIC KEY...\n\n";
|
|
61
|
+
EVP_MD_CTX *v_ctx = EVP_MD_CTX_new();
|
|
62
|
+
EVP_DigestVerifyInit(v_ctx, NULL, EVP_sha256(), NULL, pkey);
|
|
63
|
+
EVP_DigestVerifyUpdate(v_ctx, document.c_str(), document.length());
|
|
64
|
+
|
|
65
|
+
int is_valid = EVP_DigestVerifyFinal(v_ctx, signature, sig_len);
|
|
66
|
+
|
|
67
|
+
if (is_valid == 1) {
|
|
68
|
+
std::cout << "RESULT: SUCCESS! The signature is VALID.\n";
|
|
69
|
+
} else {
|
|
70
|
+
std::cout << "RESULT: FAILED! The signature is INVALID.\n";
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Cleanup
|
|
74
|
+
OPENSSL_free(signature);
|
|
75
|
+
BIO_free(pri_bio);
|
|
76
|
+
BIO_free(pub_bio);
|
|
77
|
+
EVP_MD_CTX_free(m_ctx);
|
|
78
|
+
EVP_MD_CTX_free(v_ctx);
|
|
79
|
+
EVP_PKEY_free(pkey);
|
|
80
|
+
|
|
81
|
+
return 0;
|
|
82
|
+
}
|
juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise2_Blockchain
ADDED
|
Binary file
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#include <iostream>
|
|
2
|
+
#include <vector>
|
|
3
|
+
#include <ctime>
|
|
4
|
+
#include <string>
|
|
5
|
+
using namespace std;
|
|
6
|
+
|
|
7
|
+
class Block {
|
|
8
|
+
public:
|
|
9
|
+
int index;
|
|
10
|
+
string transactions;
|
|
11
|
+
string prevHash;
|
|
12
|
+
string currentHash;
|
|
13
|
+
time_t timeCreated;
|
|
14
|
+
|
|
15
|
+
Block(int idx, string tx, string lastHash) {
|
|
16
|
+
index = idx;
|
|
17
|
+
transactions = tx;
|
|
18
|
+
prevHash = lastHash;
|
|
19
|
+
timeCreated = time(0);
|
|
20
|
+
currentHash = generateHash();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
string generateHash() {
|
|
24
|
+
// We combine all data into one string to "sign" it
|
|
25
|
+
string toHash = to_string(index) + transactions + prevHash + to_string(timeCreated);
|
|
26
|
+
|
|
27
|
+
hash<string> hasher;
|
|
28
|
+
return to_string(hasher(toHash));
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// Manages the list of blocks
|
|
33
|
+
class Blockchain {
|
|
34
|
+
public:
|
|
35
|
+
vector<Block> ledger;
|
|
36
|
+
|
|
37
|
+
Blockchain() {
|
|
38
|
+
// Create the first "Genesis" block manually
|
|
39
|
+
ledger.push_back(Block(0, "Initial Block", "0"));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
void addTransaction(string data) {
|
|
43
|
+
// Get the hash of the very last block in our ledger
|
|
44
|
+
string lastBlockHash = ledger.back().currentHash;
|
|
45
|
+
|
|
46
|
+
// Create a new block linked to the last one
|
|
47
|
+
ledger.push_back(Block(ledger.size(), data, lastBlockHash));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
void displayChain() {
|
|
51
|
+
for (const auto& b : ledger) {
|
|
52
|
+
cout << "--- Block #" << b.index << " ---" << endl;
|
|
53
|
+
cout << "Time: " << b.timeCreated << endl;
|
|
54
|
+
cout << "Data: " << b.transactions << endl;
|
|
55
|
+
cout << "Prev: " << b.prevHash << endl;
|
|
56
|
+
cout << "Hash: " << b.currentHash << endl << endl;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
int main() {
|
|
62
|
+
Blockchain bitCoin;
|
|
63
|
+
|
|
64
|
+
bitCoin.addTransaction("I have 40 bit coin");
|
|
65
|
+
bitCoin.addTransaction("Aman have 30 bicoin");
|
|
66
|
+
|
|
67
|
+
bitCoin.displayChain();
|
|
68
|
+
return 0;
|
|
69
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#include <iostream>
|
|
2
|
+
#include <openssl/sha.h>
|
|
3
|
+
#include <iomanip>
|
|
4
|
+
#include <string>
|
|
5
|
+
#include <sstream>
|
|
6
|
+
using namespace std;
|
|
7
|
+
|
|
8
|
+
string getSHA256(string input) {
|
|
9
|
+
unsigned char hash[SHA256_DIGEST_LENGTH];
|
|
10
|
+
|
|
11
|
+
SHA256(reinterpret_cast<const unsigned char*>(input.c_str()), input.size(), hash);
|
|
12
|
+
|
|
13
|
+
stringstream ss;
|
|
14
|
+
for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) {
|
|
15
|
+
ss << hex << setw(2) << setfill('0') << (int)hash[i];
|
|
16
|
+
}
|
|
17
|
+
return ss.str();
|
|
18
|
+
}
|
|
19
|
+
int main() {
|
|
20
|
+
string userInput;
|
|
21
|
+
cout << " SHA-256 HASH GENERATOR " << endl;
|
|
22
|
+
|
|
23
|
+
cout << "Enter text to hash: ";
|
|
24
|
+
getline(cin, userInput); // Allows spaces in input
|
|
25
|
+
|
|
26
|
+
string result = getSHA256(userInput);
|
|
27
|
+
|
|
28
|
+
cout << "\nInput String : " << userInput << endl;
|
|
29
|
+
cout << "Message Digest: " << result << endl;
|
|
30
|
+
return 0;
|
|
31
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#include <iostream>
|
|
2
|
+
#include <openssl/sha.h>
|
|
3
|
+
#include <iomanip>
|
|
4
|
+
using namespace std;
|
|
5
|
+
|
|
6
|
+
int main() {
|
|
7
|
+
string msg = "Blockchain Developer";
|
|
8
|
+
unsigned char hash[SHA256_DIGEST_LENGTH];
|
|
9
|
+
|
|
10
|
+
SHA256(reinterpret_cast<const unsigned char*>(msg.c_str()), msg.size(), hash);
|
|
11
|
+
|
|
12
|
+
cout << "Message : " << msg << endl;
|
|
13
|
+
cout << "SHA256 Hash : ";
|
|
14
|
+
|
|
15
|
+
for (int i = 0; i < SHA256_DIGEST_LENGTH; i++)
|
|
16
|
+
cout << hex << setw(2) << setfill('0') << (int)hash[i];
|
|
17
|
+
|
|
18
|
+
cout << endl;
|
|
19
|
+
cout << "Decryption : Not possible (SHA256 is one-way)" << endl;
|
|
20
|
+
|
|
21
|
+
return 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
Binary file
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#include <iostream>
|
|
2
|
+
#include <openssl/sha.h>
|
|
3
|
+
#include <iomanip>
|
|
4
|
+
#include <string>
|
|
5
|
+
#include <sstream>
|
|
6
|
+
|
|
7
|
+
using namespace std;
|
|
8
|
+
|
|
9
|
+
string getSHA256(string input) {
|
|
10
|
+
unsigned char hash[SHA256_DIGEST_LENGTH];
|
|
11
|
+
SHA256(reinterpret_cast<const unsigned char*>(input.c_str()), input.size(), hash);
|
|
12
|
+
|
|
13
|
+
stringstream ss;
|
|
14
|
+
for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) {
|
|
15
|
+
ss << hex << setw(2) << setfill('0') << (int)hash[i];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return ss.str();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
int main() {
|
|
22
|
+
string str1 = "Hello World";
|
|
23
|
+
string str2 = "Hello world";
|
|
24
|
+
|
|
25
|
+
cout << "String 1: " << str1 << endl;
|
|
26
|
+
cout << "Hash 1 : " << getSHA256(str1) << endl;
|
|
27
|
+
|
|
28
|
+
cout << "\nString 2: " << str2 << endl;
|
|
29
|
+
cout << "Hash 2 : " << getSHA256(str2) << endl;
|
|
30
|
+
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise4_Blockchain
ADDED
|
Binary file
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#include <iostream>
|
|
2
|
+
#include <openssl/sha.h>
|
|
3
|
+
#include <iomanip>
|
|
4
|
+
#include <string>
|
|
5
|
+
#include <sstream>
|
|
6
|
+
|
|
7
|
+
using namespace std;
|
|
8
|
+
|
|
9
|
+
int main() {
|
|
10
|
+
string input = "Hello World";
|
|
11
|
+
unsigned char hash[SHA256_DIGEST_LENGTH];
|
|
12
|
+
|
|
13
|
+
// Generating the hash
|
|
14
|
+
SHA256(reinterpret_cast<const unsigned char*>(input.c_str()), input.size(), hash);
|
|
15
|
+
|
|
16
|
+
stringstream ss;
|
|
17
|
+
for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) {
|
|
18
|
+
ss << hex << setw(2) << setfill('0') << (int)hash[i];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
cout << "Input : " << input << endl;
|
|
22
|
+
cout << "SHA-256: " << ss.str() << endl;
|
|
23
|
+
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise5_Blockchain
ADDED
|
Binary file
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#include <iostream>
|
|
2
|
+
#include <cmath>
|
|
3
|
+
#include <iomanip>
|
|
4
|
+
using namespace std;
|
|
5
|
+
|
|
6
|
+
long long power(long long base, long long exp, long long mod) {
|
|
7
|
+
long long res = 1;
|
|
8
|
+
base = base % mod;
|
|
9
|
+
while (exp > 0) {
|
|
10
|
+
if (exp % 2 == 1) res = (res * base) % mod;
|
|
11
|
+
base = (base * base) % mod;
|
|
12
|
+
exp = exp / 2;
|
|
13
|
+
}
|
|
14
|
+
return res;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
int findPrivate_d(int e, int phi) {
|
|
18
|
+
for (int d = 1; d < phi; d++) {
|
|
19
|
+
if ((e * d) % phi == 1)
|
|
20
|
+
return d;
|
|
21
|
+
}
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
int main() {
|
|
25
|
+
int p = 17;
|
|
26
|
+
int q = 11;
|
|
27
|
+
int n = p * q;
|
|
28
|
+
int phi = (p - 1) * (q - 1); // Euler's Totient Function
|
|
29
|
+
|
|
30
|
+
// Given Public Exponent (e)
|
|
31
|
+
int e = 11;
|
|
32
|
+
|
|
33
|
+
// Find Private Key (d)
|
|
34
|
+
int d = findPrivate_d(e, phi);
|
|
35
|
+
|
|
36
|
+
// Original Message (Transaction Data)
|
|
37
|
+
int M = 123;
|
|
38
|
+
|
|
39
|
+
// --- RSA Encryption ---
|
|
40
|
+
long long C = power(M, e, n); // Formula: C = (M^e) % n
|
|
41
|
+
|
|
42
|
+
// --- RSA Decryption ---
|
|
43
|
+
long long decrypted_M = power(C, d, n); // Formula: Decrypted_M = (C^d) % n
|
|
44
|
+
|
|
45
|
+
cout << "--- RSA Implementation ---" << endl;
|
|
46
|
+
cout << "p: " << p << " | q: " << q << endl;
|
|
47
|
+
cout << "Public Modulus (n) : " << n << endl;
|
|
48
|
+
cout << "Euler's Totient (phi) : " << phi << endl;
|
|
49
|
+
cout << "Public Key (e) : " << e << endl;
|
|
50
|
+
cout << "Private Key (d) : " << d << endl;
|
|
51
|
+
cout << "----------------" << endl;
|
|
52
|
+
cout << "Original Message (M) : " << M << endl;
|
|
53
|
+
cout << "Encrypted Ciphertext (C) : " << C << endl;
|
|
54
|
+
cout << "Decrypted Message : " << decrypted_M << endl;
|
|
55
|
+
|
|
56
|
+
if (M == decrypted_M) {
|
|
57
|
+
cout << "\nVerification complete! Original message recovered." << endl;
|
|
58
|
+
} else {
|
|
59
|
+
cout << "\nDecryption failed." << endl;
|
|
60
|
+
}
|
|
61
|
+
return 0;
|
|
62
|
+
}
|
juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise6_Blockchain
ADDED
|
Binary file
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#include <iostream>
|
|
2
|
+
#include <vector>
|
|
3
|
+
#include <string>
|
|
4
|
+
#include <ctime>
|
|
5
|
+
#include <sstream>
|
|
6
|
+
#include <iomanip>
|
|
7
|
+
using namespace std;
|
|
8
|
+
|
|
9
|
+
string simpleHash(string input) {
|
|
10
|
+
unsigned long hash = 5381;
|
|
11
|
+
for (size_t i = 0; i < input.length(); i++) {
|
|
12
|
+
char c = input[i];
|
|
13
|
+
hash = ((hash << 5) + hash) + c;
|
|
14
|
+
}
|
|
15
|
+
stringstream ss;
|
|
16
|
+
ss << hex << setw(8) << setfill('0') << hash;
|
|
17
|
+
return ss.str();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
class Block {
|
|
21
|
+
public:
|
|
22
|
+
int index;
|
|
23
|
+
string data;
|
|
24
|
+
string prevHash;
|
|
25
|
+
string hash;
|
|
26
|
+
int nonce;
|
|
27
|
+
|
|
28
|
+
Block(int idx, string d, string pHash) {
|
|
29
|
+
index = idx;
|
|
30
|
+
data = d;
|
|
31
|
+
prevHash = pHash;
|
|
32
|
+
nonce = 0;
|
|
33
|
+
mineBlock(); // Perform PoW immediately upon creation
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
string calculateHash() {
|
|
37
|
+
stringstream ss;
|
|
38
|
+
ss << index << data << prevHash << nonce;
|
|
39
|
+
return simpleHash(ss.str());
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
void mineBlock() {
|
|
43
|
+
string target = "00"; //Hash must start with "00"
|
|
44
|
+
do {
|
|
45
|
+
nonce++;
|
|
46
|
+
hash = calculateHash();
|
|
47
|
+
} while (hash.substr(0, 2) != target);
|
|
48
|
+
|
|
49
|
+
cout << "Block Mined! Hash: " << hash << " | Nonce: " << nonce << endl;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
class Blockchain {
|
|
54
|
+
public:
|
|
55
|
+
vector<Block> chain;
|
|
56
|
+
|
|
57
|
+
Blockchain() {
|
|
58
|
+
cout << "Mining Genesis Block..." << endl;
|
|
59
|
+
chain.push_back(Block(0, "Genesis Block", "0"));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
void addBlock(string data) {
|
|
63
|
+
cout << "Mining Block " << chain.size() << "..." << endl;
|
|
64
|
+
string lastHash = chain.back().hash;
|
|
65
|
+
chain.push_back(Block(chain.size(), data, lastHash));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
void printChain() {
|
|
69
|
+
cout << "\n--- COMPLETE BLOCKCHAIN DETAILS ---" << endl;
|
|
70
|
+
for (size_t i = 0 ; i<chain.size() ; i++) {
|
|
71
|
+
cout << "Index : " << chain[i].index << endl;
|
|
72
|
+
cout << "Data : " << chain[i].data << endl;
|
|
73
|
+
cout << "Prev Hash: " << chain[i].prevHash << endl;
|
|
74
|
+
cout << "Hash : " << chain[i].hash << endl;
|
|
75
|
+
cout << "Nonce : " << chain[i].nonce << endl;
|
|
76
|
+
cout << "-----------------------------------" << endl;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
int main() {
|
|
82
|
+
Blockchain myCoin;
|
|
83
|
+
|
|
84
|
+
myCoin.addBlock("A -> B");
|
|
85
|
+
myCoin.addBlock("B -> C");
|
|
86
|
+
myCoin.addBlock("C -> D");
|
|
87
|
+
|
|
88
|
+
myCoin.printChain();
|
|
89
|
+
|
|
90
|
+
return 0;
|
|
91
|
+
}
|
juneja_codebase-4.1.0/juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise7_Blockchain
ADDED
|
Binary file
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
#include <iostream>
|
|
2
|
+
#include <vector>
|
|
3
|
+
#include <ctime>
|
|
4
|
+
#include <sstream>
|
|
5
|
+
#include <iomanip>
|
|
6
|
+
#include <openssl/sha.h>
|
|
7
|
+
|
|
8
|
+
using namespace std;
|
|
9
|
+
|
|
10
|
+
/* ==========================================
|
|
11
|
+
SHA-256 Hash Function
|
|
12
|
+
========================================== */
|
|
13
|
+
string sha256(const string &input) {
|
|
14
|
+
unsigned char hash[SHA256_DIGEST_LENGTH];
|
|
15
|
+
|
|
16
|
+
SHA256(
|
|
17
|
+
(unsigned char*)input.c_str(),
|
|
18
|
+
input.size(),
|
|
19
|
+
hash
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
stringstream ss;
|
|
23
|
+
|
|
24
|
+
for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) {
|
|
25
|
+
ss << hex << setw(2) << setfill('0') << (int)hash[i];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return ss.str();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* ==========================================
|
|
32
|
+
Block Class
|
|
33
|
+
========================================== */
|
|
34
|
+
class Block {
|
|
35
|
+
public:
|
|
36
|
+
int index;
|
|
37
|
+
string data;
|
|
38
|
+
string previousHash;
|
|
39
|
+
string hash;
|
|
40
|
+
long timestamp;
|
|
41
|
+
|
|
42
|
+
// Constructor
|
|
43
|
+
Block(int idx, string d, string prevHash) {
|
|
44
|
+
index = idx;
|
|
45
|
+
data = d;
|
|
46
|
+
previousHash = prevHash;
|
|
47
|
+
timestamp = time(0);
|
|
48
|
+
hash = calculateHash();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Hash calculation
|
|
52
|
+
string calculateHash() const {
|
|
53
|
+
string input = to_string(index) + data + previousHash + to_string(timestamp);
|
|
54
|
+
return sha256(input);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/* ==========================================
|
|
59
|
+
Blockchain Class
|
|
60
|
+
========================================== */
|
|
61
|
+
class Blockchain {
|
|
62
|
+
public:
|
|
63
|
+
vector<Block> chain;
|
|
64
|
+
|
|
65
|
+
// Constructor
|
|
66
|
+
Blockchain() {
|
|
67
|
+
chain.push_back(createGenesisBlock());
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Genesis block
|
|
71
|
+
Block createGenesisBlock() {
|
|
72
|
+
return Block(0, "Genesis Block (Mayank)", "0");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Get latest block
|
|
76
|
+
Block getLatestBlock() {
|
|
77
|
+
return chain.back();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Add new block
|
|
81
|
+
void addBlock(string data) {
|
|
82
|
+
Block newBlock(chain.size(), data, getLatestBlock().hash);
|
|
83
|
+
chain.push_back(newBlock);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Print blockchain
|
|
87
|
+
void printChain() {
|
|
88
|
+
for (auto &block : chain) {
|
|
89
|
+
cout << "\nBlock " << block.index << endl;
|
|
90
|
+
cout << "Data : " << block.data << endl;
|
|
91
|
+
cout << "Previous Hash : " << block.previousHash << endl;
|
|
92
|
+
cout << "Hash : " << block.hash << endl;
|
|
93
|
+
cout << "--------------------------------------\n";
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Validate blockchain
|
|
98
|
+
bool isChainValid() {
|
|
99
|
+
for (int i = 1; i < chain.size(); i++) {
|
|
100
|
+
Block ¤t = chain[i];
|
|
101
|
+
Block &previous = chain[i - 1];
|
|
102
|
+
|
|
103
|
+
// Check current hash
|
|
104
|
+
if (current.hash != current.calculateHash())
|
|
105
|
+
return false;
|
|
106
|
+
|
|
107
|
+
// Check chain linking
|
|
108
|
+
if (current.previousHash != previous.hash)
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/* ==========================================
|
|
116
|
+
Main Function
|
|
117
|
+
========================================== */
|
|
118
|
+
int main() {
|
|
119
|
+
|
|
120
|
+
cout << "===== Blockchain Practical by Mayank =====\n";
|
|
121
|
+
|
|
122
|
+
Blockchain myChain;
|
|
123
|
+
|
|
124
|
+
// Adding blocks
|
|
125
|
+
myChain.addBlock("A -> B");
|
|
126
|
+
myChain.addBlock("B -> C");
|
|
127
|
+
myChain.addBlock("C -> D");
|
|
128
|
+
myChain.addBlock("D -> E");
|
|
129
|
+
myChain.addBlock("E -> F");
|
|
130
|
+
|
|
131
|
+
cout << "\n===== Original Blockchain =====\n";
|
|
132
|
+
myChain.printChain();
|
|
133
|
+
|
|
134
|
+
// Validate chain
|
|
135
|
+
cout << "\nIs Blockchain Valid? : "
|
|
136
|
+
<< (myChain.isChainValid() ? "YES" : "NO") << endl;
|
|
137
|
+
|
|
138
|
+
return 0;
|
|
139
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
contract StudentStorage {
|
|
5
|
+
|
|
6
|
+
string public name;
|
|
7
|
+
uint public age;
|
|
8
|
+
|
|
9
|
+
// Set student details
|
|
10
|
+
function setStudent(string memory _name, uint _age) public {
|
|
11
|
+
name = _name;
|
|
12
|
+
age = _age;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Get student details
|
|
16
|
+
function getStudent() public view returns (string memory, uint) {
|
|
17
|
+
return (name, age);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
contract SecureFundTransfer {
|
|
5
|
+
|
|
6
|
+
// Deposit Ether
|
|
7
|
+
function deposit() public payable {}
|
|
8
|
+
|
|
9
|
+
// Transfer using call (recommended)
|
|
10
|
+
function transferFunds(address payable recipient, uint amount) public {
|
|
11
|
+
require(address(this).balance >= amount, "Insufficient balance");
|
|
12
|
+
|
|
13
|
+
(bool success, ) = recipient.call{value: amount}("");
|
|
14
|
+
require(success, "Transfer failed");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Check balance
|
|
18
|
+
function getBalance() public view returns (uint) {
|
|
19
|
+
return address(this).balance;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: juneja-codebase
|
|
3
|
+
Version: 4.1.0
|
|
4
|
+
Summary: CLI tool to generate academic practical code files for Compiler Design, Data Structures, OS, and DBMS
|
|
5
|
+
Home-page: UNKNOWN
|
|
6
|
+
Author: AJ
|
|
7
|
+
License: UNKNOWN
|
|
8
|
+
Platform: UNKNOWN
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Intended Audience :: Education
|
|
13
|
+
Requires-Python: >=3.6
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
|
|
17
|
+
# juneja-codebase
|
|
18
|
+
|
|
19
|
+
Offline CLI for generating practical code files for multiple subjects.
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install juneja-codebase==4.1.0
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Use
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
juneja-codebase --list
|
|
31
|
+
juneja-codebase --all
|
|
32
|
+
juneja-codebase --subject compiler_design
|
|
33
|
+
juneja-codebase --subject blockchain
|
|
34
|
+
juneja-codebase --all --zip
|
|
35
|
+
juneja-codebase --all --output ./my_codes
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
If the console script is not on PATH, use:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
python3 -m juneja_codebase.main --list
|
|
42
|
+
python3 -m juneja_codebase.main --all
|
|
43
|
+
python3 -m juneja_codebase.main --subject blockchain
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Subjects
|
|
47
|
+
|
|
48
|
+
- Compiler Design
|
|
49
|
+
- Blockchain Codes
|
|
50
|
+
- Deep Learning
|
|
51
|
+
- Social Network Analysis
|
|
52
|
+
|
|
53
|
+
## Notes
|
|
54
|
+
|
|
55
|
+
- `--subject blockchain` resolves to the `Blockchain Codes` templates folder.
|
|
56
|
+
- The package works offline because templates ship inside the wheel and sdist.
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
@@ -10,6 +10,27 @@ juneja_codebase.egg-info/SOURCES.txt
|
|
|
10
10
|
juneja_codebase.egg-info/dependency_links.txt
|
|
11
11
|
juneja_codebase.egg-info/entry_points.txt
|
|
12
12
|
juneja_codebase.egg-info/top_level.txt
|
|
13
|
+
juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise1_Blockchain
|
|
14
|
+
juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise1_Blockchain.cpp
|
|
15
|
+
juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise2_Blockchain
|
|
16
|
+
juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise2_Blockchain.cpp
|
|
17
|
+
juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise3-1_Blockchain
|
|
18
|
+
juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise3-1_Blockchain.cpp
|
|
19
|
+
juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise3-2_Blockchain
|
|
20
|
+
juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise3-2_Blockchain.cpp
|
|
21
|
+
juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise3-3_Blockchain
|
|
22
|
+
juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise3-3_Blockchain.cpp
|
|
23
|
+
juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise4_Blockchain
|
|
24
|
+
juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise4_Blockchain.cpp
|
|
25
|
+
juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise5_Blockchain
|
|
26
|
+
juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise5_Blockchain.cpp
|
|
27
|
+
juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise6_Blockchain
|
|
28
|
+
juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise6_Blockchain.cpp
|
|
29
|
+
juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise7_Blockchain
|
|
30
|
+
juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise7_Blockchain.cpp
|
|
31
|
+
juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise8-1_Blockchain.sol
|
|
32
|
+
juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise8-2_Blockchain.sol
|
|
33
|
+
juneja_codebase/templates/Blockchain Codes/AnshJuneja_LabExercise8-3_Blockchain.sol
|
|
13
34
|
juneja_codebase/templates/compiler_design/AnshJuneja_Practical10_CD.l
|
|
14
35
|
juneja_codebase/templates/compiler_design/AnshJuneja_Practical10_CD.y
|
|
15
36
|
juneja_codebase/templates/compiler_design/AnshJuneja_Practical11_CD.l
|
|
@@ -7,7 +7,7 @@ long_description = (this_directory / "README.md").read_text(encoding='utf-8') if
|
|
|
7
7
|
|
|
8
8
|
setup(
|
|
9
9
|
name="juneja_codebase",
|
|
10
|
-
version="
|
|
10
|
+
version="4.1.0",
|
|
11
11
|
author="AJ",
|
|
12
12
|
description="CLI tool to generate academic practical code files for Compiler Design, Data Structures, OS, and DBMS",
|
|
13
13
|
long_description=long_description,
|
juneja_codebase-2.4.0/PKG-INFO
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: juneja_codebase
|
|
3
|
-
Version: 2.4.0
|
|
4
|
-
Summary: CLI tool to generate academic practical code files for Compiler Design, Data Structures, OS, and DBMS
|
|
5
|
-
Home-page: UNKNOWN
|
|
6
|
-
Author: AJ
|
|
7
|
-
License: UNKNOWN
|
|
8
|
-
Platform: UNKNOWN
|
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
-
Classifier: Operating System :: OS Independent
|
|
12
|
-
Classifier: Intended Audience :: Education
|
|
13
|
-
Requires-Python: >=3.6
|
|
14
|
-
Description-Content-Type: text/markdown
|
|
15
|
-
License-File: LICENSE
|
|
16
|
-
|
|
17
|
-
UNKNOWN
|
|
18
|
-
|
juneja_codebase-2.4.0/README.md
DELETED
|
File without changes
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: juneja-codebase
|
|
3
|
-
Version: 2.4.0
|
|
4
|
-
Summary: CLI tool to generate academic practical code files for Compiler Design, Data Structures, OS, and DBMS
|
|
5
|
-
Home-page: UNKNOWN
|
|
6
|
-
Author: AJ
|
|
7
|
-
License: UNKNOWN
|
|
8
|
-
Platform: UNKNOWN
|
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
-
Classifier: Operating System :: OS Independent
|
|
12
|
-
Classifier: Intended Audience :: Education
|
|
13
|
-
Requires-Python: >=3.6
|
|
14
|
-
Description-Content-Type: text/markdown
|
|
15
|
-
License-File: LICENSE
|
|
16
|
-
|
|
17
|
-
UNKNOWN
|
|
18
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{juneja_codebase-2.4.0 → juneja_codebase-4.1.0}/juneja_codebase.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|