0% found this document useful (0 votes)
12 views9 pages

Basics of Cryptograpy

The document discusses the importance of cryptography in ensuring secure communication and data protection against third parties. It explains key concepts such as plaintext, ciphertext, symmetric and asymmetric encryption, and the use of mathematical operations like XOR and modulo in cryptographic processes. Various examples of encryption methods, including DES, AES, RSA, and ECC, are provided to illustrate the principles of cryptography.

Uploaded by

10thfailgunda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views9 pages

Basics of Cryptograpy

The document discusses the importance of cryptography in ensuring secure communication and data protection against third parties. It explains key concepts such as plaintext, ciphertext, symmetric and asymmetric encryption, and the use of mathematical operations like XOR and modulo in cryptographic processes. Various examples of encryption methods, including DES, AES, RSA, and ECC, are provided to illustrate the principles of cryptography.

Uploaded by

10thfailgunda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

CRYPTOGRAPY

Have you ever wondered how to prevent third parties from


reading your messages? How can your app or web browser
build a secure channel with a remote server? By secure, we
mean that no one can read or alter the exchanged data;
furthermore, we can be confident that we are connecting
with the real server. Thanks to cryptography, these
requirements are satisfied.
Cryptography lays the foundation for our digital world.
While networking protocols have made it possible for
devices spread across the globe to communicate,
cryptography has made it possible to trust this
communication.
Cryptography’s ultimate purpose is to ensure secure
communication in the presence of adversaries. The term
secure includes confidentiality and integrity of the
communicated data. Cryptography can be defined as the
practice and study of techniques for secure communication
and data protection where we expect the presence of
adversaries and third parties. In other words, these
adversaries should not be able to disclose or alter the
contents of the messages.
Cryptography is used to protect confidentiality, integrity,
and authenticity. In this age, you use cryptography daily,
and you’re almost certainly reading this over an encrypted
connection. Consider the following scenarios where you
would use cryptography:
 When you log in to TryHackMe, your credentials are
encrypted and sent to the server so that no one can
retrieve them by snooping on your connection.
 When you connect over SSH, your SSH client and the
server establish an encrypted tunnel so no one can
eavesdrop on your session.
 When you conduct online banking, your browser
checks the remote server’s certificate to confirm that
you are communicating with your bank’s server and
not an attacker’s.
 When you download a file, how do you check if it was
downloaded correctly? Cryptography provides a
solution through hash functions to confirm that your
file is identical to the original one.

Plaintext to ciphertext
Plaintext is converted into ciphertext like Sujal to foins
or anything with a key to decrypt it, both sender and
receiver have same key to encrypt and decrypt.

 Plaintext is the original, readable message or data


before it’s encrypted. It can be a document, an image,
a multimedia file, or any other binary data.
 Ciphertext is the scrambled, unreadable version of
the message after encryption. Ideally, we cannot get
any information about the original plaintext except its
approximate size.
 Cipher is an algorithm or method to convert plaintext
into ciphertext and back again. A cipher is usually
developed by a mathematician.
 Key is a string of bits the cipher uses to encrypt or
decrypt data. In general, the used cipher is public
knowledge; however, the key must remain secret
unless it is the public key in asymmetric encryption.
We will visit asymmetric encryption in a later task.
 Encryption is the process of converting plaintext into
ciphertext using a cipher and a key. Unlike the key, the
choice of the cipher is disclosed.
 Decryption is the reverse process of encryption,
converting ciphertext back into plaintext using a
cipher and a key. Although the cipher would be public
knowledge, recovering the plaintext without
knowledge of the key should be impossible
(infeasible).
Caesar Cipher
This is the basic level of cryptography, like I have a
password Sujal then It will transform Sujal into tvkbm, it will
shift one alphabet to the right or any direction, this is weak
because anyone can decode it with online tool
Key will be 1 in this case

Types of encryptions
Symmetric Encryption
Symmetric encryption, also known as symmetric
cryptography, uses the same key to encrypt and decrypt the
data,Keeping the key secret is a must; it is also called private
key cryptography. Furthermore, communicating the key to
the intended parties can be challenging as it requires a secure
communication channel. Maintaining the secrecy of the key can
be a significant challenge, especially if there are many
recipients. The problem becomes more severe in the presence
of a powerful adversary; consider the threat of industrial
espionage, for instance.
Examples of symmetric encryption are DES (Data Encryption
Standard), 3DES (Triple DES) and AES (Advanced Encryption
Standard).
 DES was adopted as a standard in 1977 and uses a 56-bit
key. With the advancement in computing power, in 1999,
a DES key was successfully broken in less than 24 hours,
motivating the shift to 3DES.
 3DES is DES applied three times; consequently, the key
size is 168 bits, though the effective security is 112 bits.
3DES was more of an ad-hoc solution when DES was no
longer considered secure. 3DES was deprecated in 2019
and should be replaced by AES; however, it may still be
found in some legacy systems.
 AES was adopted as a standard in 2001. Its key size can
be 128, 192, or 256 bits

 Asymmetric Encryption
 Unlike symmetric encryption, which uses the same key for encryption and
decryption, asymmetric encryption uses a pair of keys, one to encrypt and the
other to decrypt, as shown in the illustration below. To protect confidentiality,
asymmetric encryption or asymmetric cryptography encrypts the data using the
public key; hence, it is also called public key cryptography.
For example, I want to send an imp information to my
friend then my friend will create and private key to decrypt
and public key to encrypt , he will send me public key
which can be seen by everyone, and I will encrypt msg and
send it to him, only he will be able to decrypt it using his
private key.
Examples are RSA, Diffie-Hellman, and Elliptic Curve
cryptography (ECC). The two keys involved in the process
are referred to as a public key and a private key. Data
encrypted with the public key can be decrypted with the
private key. Your private key needs to be kept private,
hence the name.
Asymmetric encryption tends to be slower, and many
asymmetric encryption ciphers use larger keys than
symmetric encryption. For example, RSA uses 2048-bit,
3072-bit, and 4096-bit keys; 2048-bit is the recommended
minimum key size. Diffie-Hellman also has a recommended
minimum key size of 2048 bits but uses 3072-bit and 4096-
bit keys for enhanced security. On the other hand, ECC can
achieve equivalent security with shorter keys. For example,
with a 256-bit key, ECC provides a level of security
comparable to a 3072-bit RSA key.
Asymmetric encryption is based on a particular group of
mathematical problems that are easy to compute in one
direction but extremely difficult to reverse. In this context,
extremely difficult means practically infeasible. For
example, we can rely on a mathematical problem that
would take a very long time, for example, millions of years,
to solve using today’s technology.

XOR Operation
XOR, short for “exclusive OR”, is a logical operation in
binary arithmetic that plays a crucial role in various
computing and cryptographic applications. In
binary, XOR compares two bits and returns 1 if the bits are
different and 0 if they are the same, as shown in the truth

symbol ⊕ or ^.
table below. This operation is often represented by the

A B A⊕B
0 0 0
0 1 1
1 0 1
1 1 0
If this is the first time you work with a truth table, it is a

above states all four cases: 0 ⊕ 0 = 0, 0 ⊕ 1 = 1, 1 ⊕ 0 = 1,


table that shows all possible outcomes. The XOR truth table

and 1 ⊕ 1 = 0.
Let’s consider an example where we want to apply XOR to

perform the operation bit by bit: 1 ⊕ 1 = 0, 0 ⊕ 1 = 1, 1 ⊕


the binary numbers 1010 and 1100. In this case, we

0 = 1, and 0 ⊕ 0 = 0, resulting in 0110.


You may be wondering how XOR can play any role in
cryptography. XOR has several interesting properties that
make it useful in cryptography and error detection. One key
property is that applying XOR to a value with itself results

unchanged. This means A ⊕ A = 0, and A ⊕ 0 = A for any


in 0, and applying XOR to any value with 0 leaves it

binary value A. Additionally, XOR is commutative, i.e., A ⊕


B = B ⊕ A. And it is associative, i.e., (A ⊕ B) ⊕ C = A ⊕ (B ⊕
C).
Let’s see how we can make use of the above in
cryptography. We will demonstrate how XOR can be used
as a basic symmetric encryption algorithm. Consider the

secret key. The ciphertext is C = P ⊕ K.


binary values P and K, where P is the plaintext, and K is the

⊕ K = (P ⊕ K) ⊕ K. But we know that (P ⊕ K) ⊕ K = P ⊕ (K ⊕


Now, if we know C and K, we can recover P. We start with C

K ⊕ K = 0; consequently, (P ⊕ K) ⊕ K = P ⊕ (K ⊕ K) = P ⊕ 0
K) because XOR is associative. Furthermore, we know that

= P. In other words, XOR served as a simple symmetric


encryption algorithm. In practice, it is more complicated as
we need a secret key as long as the plaintext.

Modulo Operation
Another mathematical operation we often encounter in
cryptography is the modulo operator, commonly written
as % or as mod. The modulo operator, X%Y, is
the remainder when X is divided by Y. In our daily life
calculations, we focus more on the result of division than
on the remainder. The remainder plays a significant role in
cryptography.
You need to work with large numbers when solving some
cryptography exercises. If your calculator fails, we suggest
using a programming language such as Python. Python has
a built-in int type that can handle integers of arbitrary size
and would automatically switch to larger types as needed.
Many other programming languages have dedicated
libraries for big integers. If you prefer to do your math
online, consider WolframAlpha.
Let’s consider a few examples.
 25%5 = 0 because 25 divided by 5 is 5, with a
remainder of 0, i.e., 25 = 5 × 5 + 0
 23%6 = 5 because 23 divided by 6 is 3, with a
remainder of 5, i.e., 23 = 3 × 6 + 5
 23%7 = 2 because 23 divided by 7 is 3 with a
remainder of 2, i.e., 23 = 3 × 7 + 2
An important thing to remember about modulo is that it’s
not reversible. If we are given the equation x%5 = 4,
infinite values of x would satisfy this equation.
The modulo operation always returns a non-negative result
less than the divisor. This means that for any integer a and
positive integer n, the result of a%n will always be in the
range 0 to n − 1.

You might also like