aunties 0.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.
aunties-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,120 @@
1
+ Metadata-Version: 2.4
2
+ Name: aunties
3
+ Version: 0.1.0
4
+ Summary: A simple library for displaying AI and Cybersecurity practical source code
5
+ Author: Aunties Contributors
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.9
8
+ Description-Content-Type: text/markdown
9
+
10
+ # Aunties — Python Practical Code Library
11
+
12
+ Aunties is a simple, free Python library that provides source code for practical programs from two subjects:
13
+
14
+ - **Artificial Intelligence (AI)**
15
+ - **Cyber and Information Security (CIS)**
16
+
17
+ The library allows users to display the complete source code of a practical directly in the terminal using a simple Python function.
18
+
19
+ ## Features
20
+
21
+ - Stores practical programs organized by subject.
22
+ - Displays source code using a simple keyword.
23
+ - Preserves indentation, blank lines, and code formatting.
24
+ - Supports adding new practicals without modifying the main function.
25
+ - Open-source and designed for students and learners.
26
+
27
+ ## Installation
28
+
29
+ Install the library using pip:
30
+
31
+ ```bash
32
+ pip install aunties
33
+ ```
34
+
35
+ *Note: This command will work once the package has been published on PyPI. To install the project before publication, see the Development section.*
36
+
37
+ ## Usage
38
+
39
+ Import the `show` function:
40
+
41
+ ```python
42
+ from aunties import show
43
+ ```
44
+
45
+ Display a practical by passing its keyword:
46
+
47
+ ```python
48
+ show("caesar")
49
+ ```
50
+
51
+ Display another practical:
52
+
53
+ ```python
54
+ show("rsa")
55
+ ```
56
+
57
+ The library prints the complete source code of the selected practical in the terminal.
58
+
59
+ ## Available Practicals
60
+
61
+ Practical keywords are based on their filenames without the `.py` extension.
62
+
63
+ | Subject | Filename | Keyword |
64
+ |---|---|---|
65
+ | Cyber and Information Security | `caesar.py` | `caesar` |
66
+ | Cyber and Information Security | `rsa.py` | `rsa` |
67
+ | Artificial Intelligence | `bfs.py` | `bfs` |
68
+ | Artificial Intelligence | `minimax.py` | `minimax` |
69
+
70
+ The table shows examples. Actual availability depends on the practical files included in the installed version.
71
+
72
+ ## Project Structure
73
+
74
+ ```text
75
+ aunties/
76
+ ├── pyproject.toml
77
+ ├── README.md
78
+ └── src/
79
+ └── aunties/
80
+ ├── __init__.py
81
+ ├── show.py
82
+ └── codes/
83
+ ├── ai/
84
+ └── cis/
85
+ ```
86
+
87
+ ## Adding a New Practical
88
+
89
+ 1. Open the appropriate subject folder inside `codes/`.
90
+ 2. Create a Python file, such as `vigenere.py`.
91
+ 3. Add the practical's source code to that file.
92
+ 4. Use its filename as the keyword:
93
+
94
+ ```python
95
+ show("vigenere")
96
+ ```
97
+
98
+ No changes to `show.py` are required when adding a uniquely named practical.
99
+
100
+ ## Development
101
+
102
+ To install the project locally in editable mode, clone or download the repository, navigate to its root directory, and run:
103
+
104
+ ```bash
105
+ python -m pip install -e .
106
+ ```
107
+
108
+ You can then import and test the library in your Python scripts.
109
+
110
+ ## Important Note
111
+
112
+ Aunties displays source code as text. It does not execute the displayed practical or perform encryption, decryption, or AI operations automatically.
113
+
114
+ ## Contributing
115
+
116
+ Contributions are welcome. You can help by adding practical programs, improving documentation, fixing bugs, or suggesting improvements.
117
+
118
+ ## License
119
+
120
+ This project is intended to be open-source. The
@@ -0,0 +1,111 @@
1
+ # Aunties — Python Practical Code Library
2
+
3
+ Aunties is a simple, free Python library that provides source code for practical programs from two subjects:
4
+
5
+ - **Artificial Intelligence (AI)**
6
+ - **Cyber and Information Security (CIS)**
7
+
8
+ The library allows users to display the complete source code of a practical directly in the terminal using a simple Python function.
9
+
10
+ ## Features
11
+
12
+ - Stores practical programs organized by subject.
13
+ - Displays source code using a simple keyword.
14
+ - Preserves indentation, blank lines, and code formatting.
15
+ - Supports adding new practicals without modifying the main function.
16
+ - Open-source and designed for students and learners.
17
+
18
+ ## Installation
19
+
20
+ Install the library using pip:
21
+
22
+ ```bash
23
+ pip install aunties
24
+ ```
25
+
26
+ *Note: This command will work once the package has been published on PyPI. To install the project before publication, see the Development section.*
27
+
28
+ ## Usage
29
+
30
+ Import the `show` function:
31
+
32
+ ```python
33
+ from aunties import show
34
+ ```
35
+
36
+ Display a practical by passing its keyword:
37
+
38
+ ```python
39
+ show("caesar")
40
+ ```
41
+
42
+ Display another practical:
43
+
44
+ ```python
45
+ show("rsa")
46
+ ```
47
+
48
+ The library prints the complete source code of the selected practical in the terminal.
49
+
50
+ ## Available Practicals
51
+
52
+ Practical keywords are based on their filenames without the `.py` extension.
53
+
54
+ | Subject | Filename | Keyword |
55
+ |---|---|---|
56
+ | Cyber and Information Security | `caesar.py` | `caesar` |
57
+ | Cyber and Information Security | `rsa.py` | `rsa` |
58
+ | Artificial Intelligence | `bfs.py` | `bfs` |
59
+ | Artificial Intelligence | `minimax.py` | `minimax` |
60
+
61
+ The table shows examples. Actual availability depends on the practical files included in the installed version.
62
+
63
+ ## Project Structure
64
+
65
+ ```text
66
+ aunties/
67
+ ├── pyproject.toml
68
+ ├── README.md
69
+ └── src/
70
+ └── aunties/
71
+ ├── __init__.py
72
+ ├── show.py
73
+ └── codes/
74
+ ├── ai/
75
+ └── cis/
76
+ ```
77
+
78
+ ## Adding a New Practical
79
+
80
+ 1. Open the appropriate subject folder inside `codes/`.
81
+ 2. Create a Python file, such as `vigenere.py`.
82
+ 3. Add the practical's source code to that file.
83
+ 4. Use its filename as the keyword:
84
+
85
+ ```python
86
+ show("vigenere")
87
+ ```
88
+
89
+ No changes to `show.py` are required when adding a uniquely named practical.
90
+
91
+ ## Development
92
+
93
+ To install the project locally in editable mode, clone or download the repository, navigate to its root directory, and run:
94
+
95
+ ```bash
96
+ python -m pip install -e .
97
+ ```
98
+
99
+ You can then import and test the library in your Python scripts.
100
+
101
+ ## Important Note
102
+
103
+ Aunties displays source code as text. It does not execute the displayed practical or perform encryption, decryption, or AI operations automatically.
104
+
105
+ ## Contributing
106
+
107
+ Contributions are welcome. You can help by adding practical programs, improving documentation, fixing bugs, or suggesting improvements.
108
+
109
+ ## License
110
+
111
+ This project is intended to be open-source. The
@@ -0,0 +1,20 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "aunties"
7
+ version = "0.1.0"
8
+ description = "A simple library for displaying AI and Cybersecurity practical source code"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "MIT"
12
+ authors = [
13
+ { name = "Aunties Contributors" }
14
+ ]
15
+
16
+ [tool.setuptools.packages.find]
17
+ where = ["src"]
18
+
19
+ [tool.setuptools.package-data]
20
+ aunties = ["codes/**/*.py"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ from .show import show
2
+
3
+ __all__ = ["show"]
@@ -0,0 +1,33 @@
1
+ from sklearn.datasets import load_breast_cancer
2
+ from sklearn.model_selection import train_test_split
3
+ from sklearn.tree import DecisionTreeClassifier
4
+ from sklearn.ensemble import AdaBoostClassifier
5
+ from sklearn.metrics import accuracy_score
6
+ import matplotlib.pyplot as plt
7
+
8
+ data = load_breast_cancer()
9
+ X, y = data.data, data.target
10
+
11
+ X_train, X_test, y_train, y_test = train_test_split(
12
+ X, y, test_size=0.3, random_state=4
13
+ )
14
+
15
+ weak = DecisionTreeClassifier(max_depth=1, random_state=4)
16
+ weak.fit(X_train, y_train)
17
+ weak_acc = accuracy_score(y_test, weak.predict(X_test))
18
+
19
+ ada = AdaBoostClassifier(
20
+ estimator=DecisionTreeClassifier(max_depth=1),
21
+ n_estimators=50, random_state=4
22
+ )
23
+ ada.fit(X_train, y_train)
24
+ ada_acc = accuracy_score(y_test, ada.predict(X_test))
25
+
26
+ print("Weak Classifier Accuracy:", weak_acc)
27
+ print("AdaBoost Accuracy:", ada_acc)
28
+
29
+ plt.bar(["Weak Classifier", "AdaBoost"], [weak_acc, ada_acc])
30
+ plt.xlabel("Model")
31
+ plt.ylabel("Accuracy")
32
+ plt.title("Weak Classifier vs AdaBoost")
33
+ plt.show()
@@ -0,0 +1,42 @@
1
+ import heapq
2
+
3
+ def a_star(graph, start, goal, heuristic):
4
+ queue = [(heuristic[start], start)]
5
+ cost = {start: 0}
6
+ parent = {start: None}
7
+
8
+ while queue:
9
+ _, node = heapq.heappop(queue)
10
+
11
+ if node == goal:
12
+ path = []
13
+ while node is not None:
14
+ path.append(node)
15
+ node = parent[node]
16
+ return path[::-1], cost[goal]
17
+
18
+ for neighbor, weight in graph[node]:
19
+ new_cost = cost[parent[node]] + weight if False else cost.get(node, 0) + weight
20
+
21
+ if neighbor not in cost or new_cost < cost[neighbor]:
22
+ cost[neighbor] = new_cost
23
+ parent[neighbor] = node
24
+ heapq.heappush(queue, (new_cost + heuristic[neighbor], neighbor))
25
+
26
+ return None, float("inf")
27
+
28
+
29
+ graph = {
30
+ 'A': [('B', 1), ('C', 4)],
31
+ 'B': [('A', 1), ('C', 2), ('D', 5)],
32
+ 'C': [('A', 4), ('B', 2), ('D', 1)],
33
+ 'D': [('B', 5), ('C', 1), ('E', 3)],
34
+ 'E': [('D', 3)]
35
+ }
36
+
37
+ heuristic = {'A': 7, 'B': 6, 'C': 2, 'D': 1, 'E': 0}
38
+
39
+ path, cost = a_star(graph, 'A', 'E', heuristic)
40
+
41
+ print("A* Path:", path)
42
+ print("Path Cost:", cost)
@@ -0,0 +1,93 @@
1
+
2
+ import time
3
+ from collections import deque
4
+
5
+ graph = {
6
+ 'A': ['B', 'C'],
7
+ 'B': ['A', 'D', 'E'],
8
+ 'C': ['A', 'F'],
9
+ 'D': ['B'],
10
+ 'E': ['B', 'G', 'H'],
11
+ 'F': ['C', 'I'],
12
+ 'G': ['E'],
13
+ 'H': ['E'],
14
+ 'I': ['F']
15
+ }
16
+
17
+ START, GOAL = 'A', 'I'
18
+
19
+ #BFS
20
+
21
+ def bfs(graph, start, goal):
22
+ queue = deque([[start]])
23
+ visited = set()
24
+ count = 0
25
+
26
+ while queue:
27
+ path = queue.popleft()
28
+ node = path[-1]
29
+
30
+ if node == goal:
31
+ return path, count
32
+
33
+ if node not in visited:
34
+ visited.add(node)
35
+ count += 1
36
+
37
+ for neighbor in graph.get(node, []):
38
+ queue.append(path + [neighbor])
39
+
40
+ return None, count
41
+
42
+
43
+ def dls(graph, node, goal, depth, path, visited, count):
44
+ count[0] += 1
45
+
46
+ if node == goal:
47
+ return path
48
+
49
+ if depth == 0:
50
+ return None
51
+
52
+ visited.add(node)
53
+
54
+ for neighbor in graph.get(node, []):
55
+ if neighbor not in visited:
56
+ result = dls(graph, neighbor, goal, depth - 1,
57
+ path + [neighbor], visited, count)
58
+ if result:
59
+ return result
60
+
61
+ visited.remove(node)
62
+ return None
63
+
64
+ #IDDFS
65
+
66
+ def iddfs(graph, start, goal, max_depth=10):
67
+ count = [0]
68
+
69
+ for depth in range(max_depth + 1):
70
+ result = dls(graph, start, goal, depth,
71
+ [start], set(), count)
72
+ if result:
73
+ return result, count[0]
74
+
75
+ return None, count[0]
76
+
77
+ #Compare Both
78
+
79
+ def compare():
80
+ for name, search in [('BFS', bfs), ('IDDFS', iddfs)]:
81
+ start = time.time()
82
+ path, nodes = search(graph, START, GOAL)
83
+ elapsed = time.time() - start
84
+
85
+ print(f"\n{name} Result")
86
+ print("Path:", path)
87
+ print("Path Length:", len(path) if path else 0)
88
+ print("Nodes Expanded:", nodes)
89
+ print(f"Time Taken: {elapsed:.6f} seconds")
90
+
91
+
92
+ if __name__ == "__main__":
93
+ compare()
@@ -0,0 +1,24 @@
1
+
2
+ from sklearn.datasets import load_iris
3
+ from sklearn.model_selection import train_test_split
4
+ from sklearn.neural_network import MLPClassifier
5
+ from sklearn.metrics import accuracy_score
6
+
7
+ iris = load_iris()
8
+ X, y = iris.data, iris.target
9
+
10
+ X_train, X_test, y_train, y_test = train_test_split(
11
+ X, y, test_size=0.2, random_state=42
12
+ )
13
+
14
+ model = MLPClassifier(hidden_layer_sizes=(10,), max_iter=1000,
15
+ random_state=42)
16
+ model.fit(X_train, y_train)
17
+
18
+ pred = model.predict(X_test)
19
+ accuracy = accuracy_score(y_test, pred)
20
+
21
+ print("Actual values: ", y_test)
22
+ print("Predicted values:", pred)
23
+ print("Accuracy:", accuracy)
24
+ print("Accuracy (%):", accuracy * 100)
@@ -0,0 +1,37 @@
1
+
2
+ import matplotlib.pyplot as plt
3
+ from sklearn.datasets import load_iris
4
+ from sklearn.model_selection import train_test_split
5
+ from sklearn.naive_bayes import GaussianNB
6
+ from sklearn.metrics import accuracy_score, confusion_matrix, ConfusionMatrixDisplay
7
+
8
+ iris = load_iris()
9
+ X, y = iris.data, iris.target
10
+
11
+ X_train, X_test, y_train, y_test = train_test_split(
12
+ X, y, test_size=0.2, random_state=42
13
+ )
14
+
15
+ model = GaussianNB()
16
+ model.fit(X_train, y_train)
17
+ pred = model.predict(X_test)
18
+
19
+ accuracy = accuracy_score(y_test, pred)
20
+ print("Accuracy:", accuracy * 100, "%")
21
+ print("Class Probabilities:\n", model.predict_proba(X_test))
22
+ print("Actual Values:", y_test[:5])
23
+ print("Predicted Values:", pred[:5])
24
+
25
+ cm = confusion_matrix(y_test, pred)
26
+ ConfusionMatrixDisplay(
27
+ confusion_matrix=cm, display_labels=iris.target_names
28
+ ).plot(cmap="Blues")
29
+
30
+ plt.title("Naive Bayes Confusion Matrix")
31
+ plt.show()
32
+
33
+ plt.bar(["Accuracy"], [accuracy * 100], color="green")
34
+ plt.ylabel("Accuracy (%)")
35
+ plt.title("Naive Bayes Model Accuracy")
36
+ plt.ylim(0, 100)
37
+ plt.show()
@@ -0,0 +1,28 @@
1
+
2
+ import matplotlib.pyplot as plt
3
+ from sklearn.datasets import load_iris
4
+ from sklearn.model_selection import train_test_split
5
+ from sklearn.tree import DecisionTreeClassifier, plot_tree, export_text
6
+ from sklearn.metrics import accuracy_score, confusion_matrix, classification_report
7
+
8
+ iris = load_iris()
9
+ X, y = iris.data, iris.target
10
+
11
+ X_train, X_test, y_train, y_test = train_test_split(
12
+ X, y, test_size=0.25, random_state=42, stratify=y
13
+ )
14
+
15
+ model = DecisionTreeClassifier(random_state=42)
16
+ model.fit(X_train, y_train)
17
+ pred = model.predict(X_test)
18
+
19
+ print("Accuracy:", accuracy_score(y_test, pred))
20
+ print("Confusion Matrix:\n", confusion_matrix(y_test, pred))
21
+ print("Classification Report:\n",
22
+ classification_report(y_test, pred, target_names=iris.target_names))
23
+ print("Decision Tree:\n", export_text(model, feature_names=iris.feature_names))
24
+
25
+ plt.figure(figsize=(12, 8))
26
+ plot_tree(model, feature_names=iris.feature_names,
27
+ class_names=iris.target_names, filled=True, rounded=True)
28
+ plt.show()
@@ -0,0 +1,34 @@
1
+ from sklearn.datasets import load_iris
2
+ from sklearn.neighbors import KNeighborsClassifier
3
+ from sklearn.model_selection import train_test_split
4
+ from sklearn.metrics import accuracy_score
5
+ import matplotlib.pyplot as plt
6
+
7
+ iris = load_iris()
8
+ X, y = iris.data[:, :2], iris.target
9
+
10
+ X_train, X_test, y_train, y_test = train_test_split(
11
+ X, y, test_size=0.3, random_state=43
12
+ )
13
+
14
+ model = KNeighborsClassifier(n_neighbors=3)
15
+ model.fit(X_train, y_train)
16
+ pred = model.predict(X_test)
17
+
18
+ print("Actual values:", y_test)
19
+ print("Predicted values:", pred)
20
+ print("Accuracy:", accuracy_score(y_test, pred) * 100, "%")
21
+
22
+ new_data = [[5.0, 3.5]]
23
+ result = model.predict(new_data)[0]
24
+
25
+ print("New data:", new_data)
26
+ print("Predicted class:", result)
27
+ print("Flower name:", iris.target_names[result])
28
+
29
+ plt.scatter(X[:, 0], X[:, 1], c=y)
30
+ plt.scatter(5.0, 3.5, color="red", marker="*", s=150)
31
+ plt.xlabel("Sepal Length")
32
+ plt.ylabel("Sepal Width")
33
+ plt.title("Iris Dataset - KNN")
34
+ plt.show()
@@ -0,0 +1,19 @@
1
+ import pandas as pd
2
+ from mlxtend.frequent_patterns import apriori, association_rules
3
+
4
+ data = pd.DataFrame([
5
+ [1, 1, 1, 0],
6
+ [1, 1, 0, 1],
7
+ [1, 0, 1, 0],
8
+ [1, 1, 1, 1],
9
+ [0, 1, 1, 1]
10
+ ], columns=["Bread", "Milk", "Butter", "Eggs"])
11
+
12
+ items = apriori(data.astype(bool), min_support=0.4, use_colnames=True)
13
+ rules = association_rules(items, metric="confidence", min_threshold=0.6)
14
+
15
+ print("Frequent Itemsets:")
16
+ print(items)
17
+
18
+ print("\nAssociation Rules:")
19
+ print(rules[["antecedents", "consequents", "support", "confidence", "lift"]])
@@ -0,0 +1,33 @@
1
+ import tensorflow as tf
2
+ import matplotlib.pyplot as plt
3
+
4
+ (X_train, y_train), (X_test, y_test) = tf.keras.datasets.mnist.load_data()
5
+
6
+ X_train = X_train / 255.0
7
+ X_test = X_test / 255.0
8
+
9
+ model = tf.keras.Sequential([
10
+ tf.keras.layers.Flatten(input_shape=(28, 28)),
11
+ tf.keras.layers.Dense(128, activation="relu"),
12
+ tf.keras.layers.Dense(10, activation="softmax")
13
+ ])
14
+
15
+ model.compile(optimizer="adam",
16
+ loss="sparse_categorical_crossentropy",
17
+ metrics=["accuracy"])
18
+
19
+ model.fit(X_train, y_train, epochs=3)
20
+
21
+ loss, accuracy = model.evaluate(X_test, y_test)
22
+ print("Test Accuracy:", accuracy * 100, "%")
23
+
24
+ i = 0
25
+ prediction = model.predict(X_test[i:i+1], verbose=0)
26
+
27
+ print("Actual Digit:", y_test[i])
28
+ print("Predicted Digit:", prediction.argmax())
29
+
30
+ plt.imshow(X_test[i], cmap="gray")
31
+ plt.title("Predicted Digit: " + str(prediction.argmax()))
32
+ plt.axis("off")
33
+ plt.show()
@@ -0,0 +1,52 @@
1
+
2
+ graph = {
3
+ 'A': [('B', 1), ('C', 4)],
4
+ 'B': [('A', 1), ('C', 2), ('D', 5)],
5
+ 'C': [('A', 4), ('B', 2), ('D', 1)],
6
+ 'D': [('B', 5), ('C', 1), ('E', 3)],
7
+ 'E': [('D', 3)]
8
+ }
9
+
10
+ heuristic = {'A': 7, 'B': 6, 'C': 2, 'D': 1, 'E': 0}
11
+
12
+
13
+ def rbfs(graph, node, goal, g, limit, heuristic, path):
14
+ if node == goal:
15
+ return path, g
16
+
17
+ successors = []
18
+
19
+ for neighbor, cost in graph[node]:
20
+ if neighbor not in path:
21
+ new_g = g + cost
22
+ f = max(new_g + heuristic[neighbor], heuristic[node])
23
+ successors.append([neighbor, new_g, f])
24
+
25
+ if not successors:
26
+ return None, float("inf")
27
+
28
+ while True:
29
+ successors.sort(key=lambda x: x[2])
30
+ best = successors[0]
31
+
32
+ if best[2] > limit:
33
+ return None, best[2]
34
+
35
+ alternative = successors[1][2] if len(successors) > 1 else float("inf")
36
+
37
+ result, new_f = rbfs(
38
+ graph, best[0], goal, best[1],
39
+ min(limit, alternative), heuristic,
40
+ path + [best[0]]
41
+ )
42
+
43
+ best[2] = new_f
44
+
45
+ if result is not None:
46
+ return result, new_f
47
+
48
+
49
+ path, cost = rbfs(graph, 'A', 'E', 0, float("inf"), heuristic, ['A'])
50
+
51
+ print("RBFS Path:", path)
52
+ print("Path Cost:", cost)
@@ -0,0 +1,40 @@
1
+
2
+ from sklearn.datasets import load_iris
3
+ from sklearn.svm import SVC
4
+ from sklearn.model_selection import train_test_split
5
+ from sklearn.metrics import accuracy_score, confusion_matrix, classification_report
6
+ import matplotlib.pyplot as plt
7
+
8
+ iris = load_iris()
9
+ X, y = iris.data, iris.target
10
+
11
+ mask = y != 2
12
+ X, y = X[mask, :2], y[mask]
13
+
14
+ X_train, X_test, y_train, y_test = train_test_split(
15
+ X, y, test_size=0.3, random_state=43
16
+ )
17
+
18
+ model = SVC(kernel='linear')
19
+ model.fit(X_train, y_train)
20
+ pred = model.predict(X_test)
21
+
22
+ print("Actual values:", y_test)
23
+ print("Predicted values:", pred)
24
+ print("Accuracy:", accuracy_score(y_test, pred) * 100, "%")
25
+ print("Confusion Matrix:\n", confusion_matrix(y_test, pred))
26
+ print("Classification Report:\n", classification_report(y_test, pred))
27
+
28
+ new_data = [[5.0, 3.5]]
29
+ result = model.predict(new_data)[0]
30
+
31
+ print("New data:", new_data)
32
+ print("Predicted class:", result)
33
+ print("Flower name:", iris.target_names[result])
34
+
35
+ plt.scatter(X[:, 0], X[:, 1], c=y)
36
+ plt.scatter(5.0, 3.5, color='red', marker='*', s=150)
37
+ plt.xlabel("Sepal Length")
38
+ plt.ylabel("Sepal Width")
39
+ plt.title("Iris Dataset - SVM")
40
+ plt.show()
@@ -0,0 +1,54 @@
1
+ #command
2
+ "openssl req -x509 -newkey rsa:2048 -keyout server.key -out server.crt -days 365 -nodes"
3
+
4
+
5
+ #Client Side
6
+
7
+
8
+ import socket
9
+ import ssl
10
+
11
+ context = ssl.create_default_context()
12
+ context.check_hostname = False
13
+ context.verify_mode = ssl.CERT_NONE
14
+
15
+ with socket.create_connection(("localhost", 5000)) as s:
16
+ with context.wrap_socket(s, server_hostname="localhost") as conn:
17
+ print("TLS Version:", conn.version())
18
+
19
+ while True:
20
+ msg = input("You: ")
21
+ conn.sendall(msg.encode())
22
+ print("Server:", conn.recv(1024).decode())
23
+
24
+ if msg.upper() == "BYE":
25
+ break
26
+
27
+ #Server Side
28
+
29
+
30
+ import socket
31
+ import ssl
32
+
33
+ context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
34
+ context.load_cert_chain("server.crt", "server.key")
35
+
36
+ server = socket.socket()
37
+ server.bind(("localhost", 5000))
38
+ server.listen(1)
39
+
40
+ print("TLS Server running...")
41
+
42
+ while True:
43
+ client, address = server.accept()
44
+
45
+ with context.wrap_socket(client, server_side=True) as conn:
46
+ print("Secure connection:", address)
47
+
48
+ while True:
49
+ msg = conn.recv(1024).decode()
50
+ print("Client:", msg)
51
+ conn.sendall(b"Message Received")
52
+
53
+ if msg.upper() == "BYE":
54
+ break
@@ -0,0 +1,19 @@
1
+ def encrypt(text, shift):
2
+ result = ""
3
+
4
+ for ch in text:
5
+ if ch.isalpha():
6
+ start = ord('A') if ch.isupper() else ord('a')
7
+ result += chr((ord(ch) - start + shift) % 26 + start)
8
+ else:
9
+ result += ch
10
+
11
+ return result
12
+
13
+
14
+ message = input("Enter Message: ")
15
+ shift = int(input("Enter Shift Value: "))
16
+
17
+ encrypted = encrypt(message, shift)
18
+ print("Encrypted Message:", encrypted)
19
+ print("Decrypted Message:", encrypt(encrypted, -shift))
@@ -0,0 +1,21 @@
1
+ def encrypt(text, rails):
2
+ fence = [''] * rails
3
+ row, step = 0, 1
4
+
5
+ for ch in text:
6
+ fence[row] += ch
7
+ if row == 0:
8
+ step = 1
9
+ elif row == rails - 1:
10
+ step = -1
11
+ row += step
12
+
13
+ return ''.join(fence)
14
+
15
+
16
+ msg = input("Enter Message: ")
17
+ rails = int(input("Enter Rails: "))
18
+
19
+ cipher = encrypt(msg, rails)
20
+
21
+ print("Encrypted Message:", cipher)
@@ -0,0 +1,33 @@
1
+ #Sender
2
+
3
+ p = int(input("Enter prime number p: "))
4
+ g = int(input("Enter primitive root g: "))
5
+
6
+ a = int(input("Enter Sender private key: "))
7
+
8
+ A = pow(g, a, p)
9
+
10
+ print("\nSender Public Key:", A)
11
+
12
+ B = int(input("Enter Receiver Public Key: "))
13
+
14
+ shared_key = pow(B, a, p)
15
+
16
+ print("Sender Shared Key:", shared_key)
17
+
18
+ #Reciever
19
+
20
+ p = int(input("Enter prime number p: "))
21
+ g = int(input("Enter primitive root g: "))
22
+
23
+ b = int(input("Enter Receiver private key: "))
24
+
25
+ B = pow(g, b, p)
26
+
27
+ print("\nReceiver Public Key:", B)
28
+
29
+ A = int(input("Enter Sender Public Key: "))
30
+
31
+ shared_key = pow(A, b, p)
32
+
33
+ print("Receiver Shared Key:", shared_key)
@@ -0,0 +1,34 @@
1
+ #sender
2
+
3
+ import hmac
4
+ import hashlib
5
+
6
+ message = input("Enter Message: ")
7
+ key = input("Enter Secret Key: ")
8
+
9
+ mac = hmac.new(key.encode(), message.encode(), hashlib.sha256).hexdigest()
10
+
11
+ print("\n----- Sender -----")
12
+ print("Message :", message)
13
+ print("Key :", key)
14
+ print("Generated MAC :", mac)
15
+
16
+ #reciever
17
+
18
+ import hmac
19
+ import hashlib
20
+
21
+
22
+ received_message = input("Enter Received Message: ")
23
+ key = input("Enter Secret Key: ")
24
+ received_mac = input("Enter Received MAC: ")
25
+
26
+ new_mac = hmac.new(key.encode(), received_message.encode(), hashlib.sha256).hexdigest()
27
+
28
+
29
+ if hmac.compare_digest(new_mac, received_mac):
30
+ print("\nMessage is Authentic.")
31
+ print("MAC Verification Successful.")
32
+ else:
33
+ print("\nMessage Authentication Failed!")
34
+ print("Message has been Tampered.")
@@ -0,0 +1,46 @@
1
+ #IDS
2
+
3
+
4
+ from scapy.all import sniff, IP, TCP, get_if_list
5
+
6
+ ports = {}
7
+ THRESHOLD = 5
8
+
9
+ def detect(packet):
10
+ if packet.haslayer(IP) and packet.haslayer(TCP):
11
+ ip = packet[IP].src
12
+ port = packet[TCP].dport
13
+
14
+ if packet[TCP].flags == "S":
15
+ ports.setdefault(ip, set()).add(port)
16
+ print(f"Connection attempt: {ip} -> Port {port}")
17
+
18
+ if len(ports[ip]) >= THRESHOLD:
19
+ print(f"[ALERT] Possible Port Scan from {ip}")
20
+ ports[ip].clear()
21
+
22
+ print("Python Based IDS Running...")
23
+ interfaces = get_if_list()
24
+ print("Interfaces:", interfaces)
25
+
26
+ sniff(iface=interfaces, filter="tcp", prn=detect, store=False)
27
+
28
+
29
+ #TEST
30
+
31
+
32
+ import socket
33
+
34
+ target = "127.0.0.1"
35
+
36
+ print("Starting Port Scan Test...")
37
+
38
+ for port in range(5000, 5051):
39
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
40
+ s.settimeout(0.1)
41
+ result = s.connect_ex((target, port))
42
+
43
+ print(f"Port {port}:", "OPEN" if result == 0 else "CLOSED")
44
+ s.close()
45
+
46
+ print("Port Testing Completed.")
@@ -0,0 +1,58 @@
1
+ #Sender
2
+
3
+ from cryptography.hazmat.primitives.asymmetric import rsa, padding
4
+ from cryptography.hazmat.primitives import hashes, serialization
5
+
6
+ private_key = rsa.generate_private_key(public_exponent=65537, key_size=2048)
7
+ public_key = private_key.public_key()
8
+
9
+ with open("public_key.pem", "wb") as f:
10
+ f.write(public_key.public_bytes(
11
+ serialization.Encoding.PEM,
12
+ serialization.PublicFormat.SubjectPublicKeyInfo
13
+ ))
14
+
15
+ message = b"Hello Receiver"
16
+
17
+ signature = private_key.sign(
18
+ message,
19
+ padding.PSS(mgf=padding.MGF1(hashes.SHA256()),
20
+ salt_length=padding.PSS.MAX_LENGTH),
21
+ hashes.SHA256()
22
+ )
23
+
24
+ open("message.txt", "wb").write(message)
25
+ open("signature.sig", "wb").write(signature)
26
+
27
+ print("Message and Signature Sent")
28
+
29
+
30
+ #Reciever
31
+
32
+
33
+ from cryptography.hazmat.primitives.asymmetric import padding
34
+ from cryptography.hazmat.primitives import hashes, serialization
35
+ from cryptography.exceptions import InvalidSignature
36
+
37
+ with open("public_key.pem", "rb") as f:
38
+ public_key = serialization.load_pem_public_key(f.read())
39
+
40
+ with open("message.txt", "rb") as f:
41
+ message = f.read()
42
+
43
+ with open("signature.sig", "rb") as f:
44
+ signature = f.read()
45
+
46
+ try:
47
+ public_key.verify(
48
+ signature,
49
+ message,
50
+ padding.PSS(mgf=padding.MGF1(hashes.SHA256()),
51
+ salt_length=padding.PSS.MAX_LENGTH),
52
+ hashes.SHA256()
53
+ )
54
+ print("Signature Verified")
55
+ print("Message is Authentic")
56
+ except InvalidSignature:
57
+ print("Signature Verification Failed")
58
+ print("Message has been Tampered")
@@ -0,0 +1,37 @@
1
+ #sender
2
+
3
+ import math
4
+
5
+ p = int(input("Enter p: "))
6
+ q = int(input("Enter q: "))
7
+ message = input("Enter message: ")
8
+
9
+ n = p * q
10
+ phi = (p - 1) * (q - 1)
11
+
12
+ e = 2
13
+ while e < phi:
14
+ if math.gcd(e, phi) == 1:
15
+ break
16
+ e += 1
17
+
18
+ d = pow(e, -1, phi)
19
+
20
+ ciphertext = [str(pow(ord(ch), e, n)) for ch in message]
21
+
22
+ print("Public Key:", e, n)
23
+ print("Private Key:", d, n)
24
+ print("Cipher Text:", " ".join(ciphertext))
25
+
26
+ #reciever
27
+
28
+ d = int(input("Enter d: "))
29
+ n = int(input("Enter n: "))
30
+ ciphertext = input("Enter cipher text: ")
31
+
32
+ message = ""
33
+
34
+ for c in ciphertext.split():
35
+ message += chr(pow(int(c), d, n))
36
+
37
+ print("Decrypted Message:", message)
@@ -0,0 +1,28 @@
1
+ from pathlib import Path
2
+
3
+
4
+ def show(name):
5
+ """Print the source code of a practical by its keyword."""
6
+
7
+ if not isinstance(name, str) or not name.strip():
8
+ raise ValueError("Please provide a practical name, e.g. show('caesar').")
9
+
10
+ name = name.strip().lower()
11
+ codes_dir = Path(__file__).parent / "codes"
12
+
13
+ matches = [
14
+ file
15
+ for file in codes_dir.rglob("*.py")
16
+ if file.stem.lower() == name
17
+ ]
18
+
19
+ if not matches:
20
+ print(f"Practical '{name}' was not found.")
21
+ return
22
+
23
+ if len(matches) > 1:
24
+ print(f"Multiple practicals named '{name}' were found.")
25
+ return
26
+
27
+ source = matches[0].read_text(encoding="utf-8")
28
+ print(source, end="" if source.endswith("\n") else "\n")
@@ -0,0 +1,120 @@
1
+ Metadata-Version: 2.4
2
+ Name: aunties
3
+ Version: 0.1.0
4
+ Summary: A simple library for displaying AI and Cybersecurity practical source code
5
+ Author: Aunties Contributors
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.9
8
+ Description-Content-Type: text/markdown
9
+
10
+ # Aunties — Python Practical Code Library
11
+
12
+ Aunties is a simple, free Python library that provides source code for practical programs from two subjects:
13
+
14
+ - **Artificial Intelligence (AI)**
15
+ - **Cyber and Information Security (CIS)**
16
+
17
+ The library allows users to display the complete source code of a practical directly in the terminal using a simple Python function.
18
+
19
+ ## Features
20
+
21
+ - Stores practical programs organized by subject.
22
+ - Displays source code using a simple keyword.
23
+ - Preserves indentation, blank lines, and code formatting.
24
+ - Supports adding new practicals without modifying the main function.
25
+ - Open-source and designed for students and learners.
26
+
27
+ ## Installation
28
+
29
+ Install the library using pip:
30
+
31
+ ```bash
32
+ pip install aunties
33
+ ```
34
+
35
+ *Note: This command will work once the package has been published on PyPI. To install the project before publication, see the Development section.*
36
+
37
+ ## Usage
38
+
39
+ Import the `show` function:
40
+
41
+ ```python
42
+ from aunties import show
43
+ ```
44
+
45
+ Display a practical by passing its keyword:
46
+
47
+ ```python
48
+ show("caesar")
49
+ ```
50
+
51
+ Display another practical:
52
+
53
+ ```python
54
+ show("rsa")
55
+ ```
56
+
57
+ The library prints the complete source code of the selected practical in the terminal.
58
+
59
+ ## Available Practicals
60
+
61
+ Practical keywords are based on their filenames without the `.py` extension.
62
+
63
+ | Subject | Filename | Keyword |
64
+ |---|---|---|
65
+ | Cyber and Information Security | `caesar.py` | `caesar` |
66
+ | Cyber and Information Security | `rsa.py` | `rsa` |
67
+ | Artificial Intelligence | `bfs.py` | `bfs` |
68
+ | Artificial Intelligence | `minimax.py` | `minimax` |
69
+
70
+ The table shows examples. Actual availability depends on the practical files included in the installed version.
71
+
72
+ ## Project Structure
73
+
74
+ ```text
75
+ aunties/
76
+ ├── pyproject.toml
77
+ ├── README.md
78
+ └── src/
79
+ └── aunties/
80
+ ├── __init__.py
81
+ ├── show.py
82
+ └── codes/
83
+ ├── ai/
84
+ └── cis/
85
+ ```
86
+
87
+ ## Adding a New Practical
88
+
89
+ 1. Open the appropriate subject folder inside `codes/`.
90
+ 2. Create a Python file, such as `vigenere.py`.
91
+ 3. Add the practical's source code to that file.
92
+ 4. Use its filename as the keyword:
93
+
94
+ ```python
95
+ show("vigenere")
96
+ ```
97
+
98
+ No changes to `show.py` are required when adding a uniquely named practical.
99
+
100
+ ## Development
101
+
102
+ To install the project locally in editable mode, clone or download the repository, navigate to its root directory, and run:
103
+
104
+ ```bash
105
+ python -m pip install -e .
106
+ ```
107
+
108
+ You can then import and test the library in your Python scripts.
109
+
110
+ ## Important Note
111
+
112
+ Aunties displays source code as text. It does not execute the displayed practical or perform encryption, decryption, or AI operations automatically.
113
+
114
+ ## Contributing
115
+
116
+ Contributions are welcome. You can help by adding practical programs, improving documentation, fixing bugs, or suggesting improvements.
117
+
118
+ ## License
119
+
120
+ This project is intended to be open-source. The
@@ -0,0 +1,27 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/aunties/__init__.py
4
+ src/aunties/show.py
5
+ src/aunties.egg-info/PKG-INFO
6
+ src/aunties.egg-info/SOURCES.txt
7
+ src/aunties.egg-info/dependency_links.txt
8
+ src/aunties.egg-info/top_level.txt
9
+ src/aunties/codes/ai/Adaboost.py
10
+ src/aunties/codes/ai/Astar.py
11
+ src/aunties/codes/ai/BFS.py
12
+ src/aunties/codes/ai/Back.py
13
+ src/aunties/codes/ai/Bayes.py
14
+ src/aunties/codes/ai/Dtree.py
15
+ src/aunties/codes/ai/KNN.py
16
+ src/aunties/codes/ai/Mining.py
17
+ src/aunties/codes/ai/Open.py
18
+ src/aunties/codes/ai/RBFS.py
19
+ src/aunties/codes/ai/SVM.py
20
+ src/aunties/codes/cis/TLS.py
21
+ src/aunties/codes/cis/ceasar.py
22
+ src/aunties/codes/cis/fence.py
23
+ src/aunties/codes/cis/hellman.py
24
+ src/aunties/codes/cis/hmac.py
25
+ src/aunties/codes/cis/ids.py
26
+ src/aunties/codes/cis/pss.py
27
+ src/aunties/codes/cis/rsa.py
@@ -0,0 +1 @@
1
+ aunties