Interactive Cryptography Learning Platform
Interactive Cryptography Learning Platform
Project Documentation
Discrete Structures II
CSP20123X
By:
Antonio Camacho
Chyle Talledo
March 2025
0
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
COVER PAGE…………………………………………………………………………………...1
TABLE OF
CONTENTS………………………………………………………………….……..1
1. INTRODUCTION……………………………………………………………………….1
TOPICS…………………..…1
2. LITERATURE
REVIEW………………………………………………………….…….4
4. IMPLEMENTATION
DETAILS………………………………………………………18
4.1. CODE
EXPLANATION…………………………………………………………19
1
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
5. RESULTS AND
EXPLANATION……………………………………………………..22
5.1. TESTING………………………………………………………………………...23
6. CONCLUSION…………………………………………………………………………30
REFERENCES………………………………………………………………………………….35
CHAPTER I
INTRODUCTION
This application serves as an educational platform that bridges the core principles of
Discrete Structures 2 with their practical applications in modern cryptography. At its foundation,
the program emphasizes modular arithmetic—a cornerstone of cryptographic systems such as RSA
and AES, enabling secure data encryption and decryption. Additionally, it incorporates
combinatorics to model key generation processes, evaluate possible attack vectors, and assess the
computational complexity of brute-force attempts. The software further delves into number
theory, exploring prime factorization, greatest common divisors (GCD), and modular inverses—
all of which are critical for constructing secure algorithms and ensuring robust key exchanges in
how these abstract mathematical concepts underpin technologies such as end-to-end encryption,
2
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
digital signatures, and even decentralized systems like blockchain. To enhance understanding, the
platform features an interactive interface where users can experiment with cryptographic
operations, visualize algorithmic workflows, and observe the impact of different parameters on
security. This hands-on approach demystifies complex theories, making them more intuitive for
mathematics. Ultimately, the program not only reinforces theoretical knowledge but also
and infrastructure.
The purpose of this application is to provide an interactive and educational platform that
can help users in visualizing and understanding the concepts of discrete structures within
cryptography. This program enables users to experiment with different cryptographic algorithms,
This program is intended as a learning aid for diverse audience, including students who wish to
grasp cryptographic principles, educators who need a versatile tool to facilitate teaching, and
enthusiast who have an interest in the fascinating world of cryptography. This platform offers
1. Interactive Experience - This application allows users to input plaintext messages, apply a
range of cryptographic techniques, and visually observe the encryption and decryption
3
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
processes. This hands-on approach is designed to make abstract concepts more tangible,
helping users to see how algorithms like RSA or other encryption methods work in real
time.
cryptographic processes in a step by step format, clearly demonstrating how each stage of
encryption and decryption unfolds. This visualization is essential for illustrating the
discrete structure principles at play, such as modular arithmetic, number theory, and
permutations. By breaking down the processes into manageable steps, user can have better
offering a simplified yet comprehensive interface that is intuitive and easy to navigate.
Whether users are complete beginners or have some experience with cryptography, the
program provides an accessible environment for learning. The clear presentation of data
and the step-by-step nature of the visualization process ensures that the users with varying
level of expertise can effectively understand and engage with the content.
4. Education and Practical Value - In addition to the theoretical content, the application
provides opportunities for practical exercises that encourage experimentation. Users can
tweak different parameters and observe how changes affect the outcome, reinforcing their
4
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
ensures that the users not only passively receive information but also engage with the
material in a way that builds problem-solving skills and deepens their knowledge.
CHAPTER II
LITERATURE REVIEW
Over the years, there have been major developments in the fields of cryptography and
algorithm visualization, with the development of a large number of tools and frameworks to help
encryption, decryption, and key management methodologies. Tools like CrypTool and
PyCryptodome, for example, are frequently used in educational contexts to illustrate cryptographic
topics like digital signatures, hashing, and symmetric and asymmetric encryption.
But a lot of the tools that are now available don't take a thorough approach to showing the
programs offer rudimentary capability, they frequently fall short of meeting students' educational
objectives by lacking interactive features that let users change parameters and see how that affects
algorithm performance. This weakness in current resources emphasizes the need for a more
5
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
engaging and approachable method of teaching cryptography, which is what our initiative seeks
to provide.
education tool designed for K–12 students. The tool combines role-playing and visual interfaces
transaction between a user and a bank, with an attacker attempting to compromise the
communication, the tool allows students to step into the roles of both the user and the bank. This
hands-on approach helps students understand fundamental principles like confidentiality, integrity,
and authentication. The authors evaluated the tool on 58 middle and high school students, finding
that participants could readily grasp key cryptographic operations and expressed high satisfaction
with the tool. The study highlights the effectiveness of role-playing and visualization in teaching
cryptography, particularly for younger audiences. This work aligns with our project’s goal of
creating an interactive learning tool, emphasizing the importance of user engagement and practical
interactive cryptography learning tool—is extremely pertinent. Students and professionals alike
6
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
must comprehend the inner workings and intricacy of cryptographic algorithms as they grow more
The increasing need for cybersecurity knowledge across a range of industries highlights
the topic's importance. Our effort bridges the gap between theory and practice by offering a tool
that not only describes cryptographic algorithms but also illustrates their time and space
complexity. By letting users interact with the algorithms, adjust inputs, and see how performance
and output change as a result, this method improves the learning process.
of computer science education, which stress the value of effectiveness and optimization in
problem-solving. Users can better grasp how various algorithms scale with input size and why
some algorithms are better than others in particular situations by integrating complexity analysis
7
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
CHAPTER III
Programming Language:
- Python
- Python was chosen for its extensive external library for mathematical equations and
its simplicity of use. We have used libraries such as PyCryptodome and math for
platform. Flask is a lightweight web framework for Python used as the back-end
part of our web application for handling routes, user inputs, and data processing for
Tools:
- This software was chosen due to its capability to be lightweight, fast, and use less
software provides smart code suggestions and completions. This helps developers
write code more efficiently and faster. It supports Modern Web Technologies,
together with tools and templates specifically designed for those technologies.
8
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
The project implements and demonstrates the following core topics from Discrete Structures II,
1. Modular Arithmetic
- RSA Encryption/Decryption:
- Implements the fundamental operations ( C = M^e mod n ) for encryption and ( M = C^d mod
n ) for decryption, showcasing how modular arithmetic ensures data confidentiality by constraining
- Demonstrates the practical use of modular exponentiation for secure computations, including
- Key Generation:
- Applies Euler's Totient Function ( phi(n) = (p-1)(q-1) ) to determine valid public/private key
- Computes modular inverses (e.g., private key ( d ) as ( e^{-1} mod \phi(n) )) using the
Extended Euclidean Algorithm, illustrating how modular arithmetic enables secure key derivation.
2. Number Theory
9
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
- Implements probabilistic primality tests (e.g., Miller-Rabin) or deterministic checks for small
cryptographic security.
- Uses the Euclidean Algorithm to ensure the public key ( e ) is coprime with ( phi(n) ), a critical
step for RSA's correctness. Visualizes the GCD computation to teach its role in key selection.
- Explains how these theorems underpin RSA's decryption process, ensuring ( M^{ed} equiv
3. Combinatorics
- Quantifies the number of valid RSA keys for given bit-lengths of ( p ) and ( q ), demonstrating
how combinatorial growth (e.g., ( sim n^2 ) possible pairs) impacts brute-force resistance.
- Compares symmetric vs. asymmetric key spaces (e.g., 256-bit AES vs. 2048-bit RSA) to
- Password/Permutation Attacks:
- Models attacks on substitution ciphers by calculating possible permutations (e.g., ( 26! ) for
4. Algorithmic Complexity
- Time Complexity:
10
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
- Analyzes RSA's ( O(k^3) ) operations for ( k )-bit keys, contrasting with AES's ( O(n) ) for
- Profiles modular exponentiation steps (e.g., ( M^e mod n )) to show how algorithmic
- Space Complexity:
- Evaluates memory usage for storing large primes, ciphertexts, and intermediate values,
- Comparative Analysis:
- Benchmarks RSA against elliptic-curve cryptography (ECC) in terms of key sizes and
Implementation Features
- Interactive Examples: Users input values for ( p ), ( q ), and ( e ) to see real-time validation, key
11
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
- Error Handling: Rejects non-prime inputs or invalid keys with explanations, reinforcing
theoretical constraints.
- Visual Aids: Diagrams illustrate modular "wrapping," prime distributions, and combinatorial key
Figure 1.1
This figure enables the user to navigate through different main features implemented in the
study. It indicates that the user can choose Encryption, Combinatorics, or Test Yourself. If one of
the buttons is clicked, it’ll redirect the user to its respective web page.
12
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
Figure 1.2
The user can explore RSA Encryption and Decryption in this figure. This enables the user
to interact with the web page by the use of some buttons to input specific information for the
system to process. After processing, the result will be provided below, together with a step-by-step
13
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
Figure 1.3
This figure indicates the developers behind the system and the webpage. This enables the
user to know more about the developers and get their personal information. This helps the
developers to promote their name, company, and their skills in the field.
14
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
Figure 1.4
This is figure indicates our encryption selector. Users can select the encryption
techniques they want to try in this page. The options in which is RSA Encryption, Caesar Cipher,
15
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
Figure 1.5
This is our Caesar Cipher encryption page. The user can experiment with the Caesar
Cipher here and it will show the step by step process in a carousel slide.
Figure 1.6
This is our Vigenere Cipher encryption page. The user can interact with this page and
experiment with this encryption method. The step by step visualization will then be shown in a
16
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
Figure 1.7
In this page the user can answer 10 questions made by the developers. The questions are
limited to what our platform have shown to ensure that the users can answer the questions
17
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
CHAPTER IV
Implementation Details
rsa_steps(): This function is for processing and displaying our RSA cryptography
function. First it retrieves the data from the front-end using request.json method which takes the
stored value in our javascript to our back-end. After requesting the data from our front-end page
we take the integer value using the .get() method to store in a variable p,q and message. The
function then checks if the p and q value are prime or not, if the value is prime it will proceed on
the calculations and if not it will return an error message that says both numbers must be
prime.After validation the function will then compute the n by multiplying ‘p’ and ‘q’, and
calculates Euler’s Totient Function φ(n) as (p-1) * (q-1). The next step is for selecting a public key
e which we defined to start from 3, it will then continue to increment until it finds a number that
is coprime with the φ(n) meaning their greatest common divisor is 1. After selecting the public
key it will then proceed to compute the private key ‘d’ as the modular inverse of e modulo. The
function will then proceed to convert each letter in the message into numbers based on our
predefined letter map. It will then proceed to encrypt the numbers using the formula C = M^e mod
n, where M is our message number, and store the result in a list of the encrypted values. For
decryption, it will compute using the formula M = C^d mod n to retrieve the original numbers
which are then converted back into characters to reconstruct the decrypted message. Each of the
steps are document and stored in a list of dictionaries that we call ‘steps’ where “step” is the key
18
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
for the value which is number of order the RSA steps goes and “text” is the key for the value of
the text description of the process, to provide a step by step visualization of the process including
the conversation of the message, encryption of each letter, and decryption of the ciphertext. Finally,
the function will return all the steps as a JSON response to the javascript function which will then
store all the steps into a bootstrap defined carousel slides to allow users to view the entire RSA
process from the key generation to encryption and decryption of the message.
dynamically display each step of the RSA algorithm process from rsa_steps() function. It takes an
array called steps as the input, where each element contains a ‘steps’ and its corresponding ‘text’
description. First, the function selects the HTML element with the class .carousel-inner and clears
its current content to remove previous steps. It will then loop through each step using the forEach()
function, and for every step it will create a new div element representing a carousel item. The
function then assigns the class carousel-item to the div, and if the current step is the first one (index
=== 0), it adds the active class so that it will be displayed first when the carousel loads. Inside the
div, the function will then generate a Bootstrap card layout containing the step number as the title
and the corresponding description text. After the structure is created, the new carousel item is
appended to the .carousel-inner element, allowing the users to navigate through the RSA steps
fetchRSA(): This function is a JavaScript function designed to send user input data to the Flask
backend for processing the RSA algorithm. First it will retrieve the p,q, and message value from
the HTML input fields using their respective id attributes. After collecting the data, the function
19
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
sends a POST request to the flask route /rsa_steps using the fetch() API. It will then convert the
input value into a JSON format using JSON.stringify() and specify the request to headers to
indicate that the content type will be JSON. Once the request is sent, the function will await for
the response using the ‘await’ keyword and convert the response into JSON format. If the response
is successful, it calls the generateCarousel() function to display the step-by-step RSA process in
the carousel component. However if there is an error, such as invalid input like non-prime numbers,
the function triggers an alert displaying the error message returned by the Flask backend. The
function allows the front-end of the application to communicate with the Flask back-end, process
the RSA encryption and decryption, and display the results interactive on the webpage.
have faced several challenges, each requires us to carefully consider the solution for a smooth
particularly the RSA algorithm in handling large numbers and ensuring the encryption and
decryption processes worked efficiently. The mathematical complexity of RSA posed difficulties,
especially in terms of ensuring that the prime number validation, key generation, and modular
operations were performed correctly. As the input values (p, q) grew larger, the computations
needed to calculated the public and private keys became increasingly complex, resulting in
20
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
potential delays. To mitigate this we optimized the modular inverse computation and used efficient
algorithms to check prime numbers, ensuring that the application will be able to handle larger
One of the significant challenges was ensuring that the frontend and backend of the
application communicates seamlessly. This included handling the transfer of input data such as
prime numbers and messages from to frontend to the backend via API request and subsequently
sending back the results. The process of dynamically updating the frontend to display the RSA
algorithm steps required managing asynchronous tasks efficiently. The occasional synchronization
bugs caused by issues with asynchronous execution were resolved by optimizing the use of
The visualization of the RSA algorithm was another challenge. Displaying each step of the process
in a user-friendly and intuitive manner was the key to the success of the platform. The carousel
component in Bootstrap was chosen to present each steps of the algorithm in an easy-to-navigate
format. However, ensuring the dynamic generation of carousel items from the backend’s response
posed a challenge, as it required converting the data into a structure that the frontend could use.
Proper error handling and validation were incorporated to ensure that the users will receive clear
feedback in case of invalid inputs such as non-prime numbers, which improved the overall user
experience.
21
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
CHAPTER V
5.1 Testing
platform, a comprehensive set of test cases were developed. These test cases were designed to
verify core functionality, validate the input, and assess the system’s behavior under edge
conditions.
The testing process included unit testing for individual functions, integration testing
between front-end and back-end, and user interface testing to ensure correct rendering of step-by-
1. Functional Testing
These test cases verified that the program performed correctly under normal expected
conditions.
22
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
This tested the platform’s capability to handle improper or invalid input and return the
Proper error messages were displayed, enduring that the system enforces constraints and
The platform was tested against uncommon but possible user behaviors to evaluate the
Edge cases were handled correctly, the system showed no delays even when very large
23
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
The testing confirmed that the platform meets functional, input validation, and user
interface requirements. It effectively handled both valid and invalid inputs, including the edge
cases, with appropriate error handling. These validated the platform’s robustness, reliability and
The Interactive Cryptography Learning Platform was rigorously evaluated through self-
evaluation to determine its success in achieving educational objectives, practical functionality, and
usability for target audiences. This assessment combined quantitative performance metrics and
qualitative reflection to provide a holistic view of the platform’s effectiveness in teaching discrete
The platform’s development was guided by key objectives, each evaluated through self-
assessment:
cryptographic algorithms.
user input for critical parameters (prime numbers p and q, plaintext). Real-time encryption and
decryption results were provided, offering immediate feedback. Furthermore, visual feedback
24
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
● Evidence: Through self-testing, the ability to modify parameters and instantly observe
● Evidence: As a self-learner, the visual aids were critical for grasping Euler’s Totient
explaining fundamental mathematical constraints, such as the primality requirements essential for
cryptographic operations.
Self-Evaluation Insights
25
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
Through hands-on testing and reflection, the following strengths and areas for
Positive Outcomes:
● Engagement: Interactive elements, such as tweaking inputs like e to observe its impact on
parentheses)
Constructive Feedback:
limitations.
● Feature Requests: Adding a computation history log and support for more algorithms,
26
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
This section details the verification and validation procedures undertaken to ensure the
Testing Methodology
1. Mathematical Accuracy:
● The Bootstrap carousel organized steps effectively, though a progress bar could
improve navigation.
● Dynamic updates ( recalculating ϕ ( n ) ) were seamless, but latency for large inputs
3. Educational Impact:
● The platform excelled at demonstrating 'invisible' properties ( That e and ϕ (n) are
coprime).
27
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
Self-evaluation confirms the platform successfully bridges theory and practice via interactivity and
Recommendations:
By addressing these areas, the platform can further solidify its role as a versatile tool for
self-directed and classroom learning. This self-evaluation highlights the iterative design process,
where reflection and technical refinement converge to create impactful educational tools.
CHAPTER VI
Conclusion
28
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
Structures II, including modular arithmetic, number theory, and combinatorics, with
practical cryptographic applications such as RSA, Caesar Cipher, and Vigenère Cipher.
1. Educational Impact
2. Technical Performance
transformations.
RSA).
3. Comparative Advantages
29
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
education. Future iterations should address performance bottlenecks and expand algorithm
While the current version of our cryptography educational platform has achieved its goals
of guiding and introducing the users through easy to understand encryption techniques such
as RSA, Caesar, and Vigenere ciphers using interactive visualization, there are several
refinements.
computation.
30
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
the platform to include visual teaching of underlying discrete structure topics could
● Finite Fields and Rings: Explain how modular arithmetic structures support
● Number Theory Modules: Expand prime testing and introduce other topics such as
These additions would introduce a broader educational system for the users.
The current Bootstrap + Flask UI provides a clean experience, but following upgrades
the current user interface lacks an appealing user interface. Upgrading the design
31
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
● Progress Tracking System: Store user progress and suggest learning paths.
mathematical concepts like group theory and finite fields, and enhancing UI and user
experience, the platform can involve into a much more comprehensive digital textbook and
toolkit for students, educators, and enthusiast in both mathematics and cybersecurity.
32
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
REFERENCES
Rayavaram, P., Dindukuri, S. C., Vellamchety, K., Marward, J., Abbasalizadeh, M., Lee, C. S., &
Narain, S. (2024). Visual CryptoEd: A role-playing and visualization tool for K-12 cryptography
education. Proceedings of the 2024 ACM Conference on Computer Science Education, 1105–
1111. https://doi.org/10.1145/3626252.3630963
33
UNIVERSITY OF NEGROS OCCIDENTAL – RECOLETOS
CURRICULUM VITAE
34