Looking for a Tutor Near You?

Post Learning Requirement »
x

Choose Country Code

x

Direction

x

Ask a Question

x

x
x
x
Hire a Tutor

Notes On Cryptography Introduction

Loading...

Cryptography is about constructing and analyzing protocols that prevent third parties or the public from reading private messages. Various aspects of information security such as data confidentiality, data integrity, authentication, and non-repudiation are central to modern cryptography.

Prantik S / Kolkata

11 years of teaching experience

Qualification: MCA (Jaipur National University - [JNU], Jaipur - 2017)

Teaches: Basic Computer, Computer for official job, MS Office, School Level Computer, ICT Training, Computer Science, Information Practice, IT & Computer Subjects, BCA Tuition, IT, Computer, C / C++, C# (C Sharp), Java And J2EE, Python Programming, Visual Basic, BCA Subjects, Hardware Training, Networking, Java Script

Contact this Tutor
  1. What is Cryptography? Cryptography is about constructing and analyzing protocols that prevent third parties or the public from reading private messages. Various aspects of information security such as data confidentiality, data integrity, authentication, and non-repudiation are central to modern cryptography. Prior to the modern age, cryptography was effectively synonymous with encryption, the conversion of information from a readable state to apparent nonsense. Modern cryptography is heavily based on mathematical theory and computer science. Cryptographic algorithms are designed around computational hardness assumptions, making the algorithms hard for adversaries to break. There exist information-theoretically secure schemes that probably cannot be broken even with unlimited computing power. Note: Cryptography also plays a major role in digital rights management and copyright infringement of digital media. Caesar Cipher
  2. The Caesar cipher is one of the earliest known and simplest ciphers. It is a type of substitution cipher in which each letter in the plaintext is shifted to a certain number of places down the alphabet. For example, with a shift of 1, A would be replaced by B, B would become C, and so on. The method is named after Julius Caesar, who allegedly used it to communicate with his generals. Here is a quick example of the encryption and decryption steps involved with the Caesar cipher. The text we will encrypt is "defend the east wall of the castle," with a shift (key) of 1 . Plaintext: "defend the east wall of the castle" Ciphertext: "efgfoe uif fbtu xbmm pg uif dbtumf" It is easy to see how each character in the plaintext is shifted up the alphabet. Decryption is just as easy, by using an offset of -1 . Another example:
  3. Plaintext: "abcdefghijklmnopqrstuvwxyz" Ciphertext: "bcdefghijklmnopqrstuvwxyza" The text above is shifted by 1 offset. Note: If a different key is used, the cipher alphabet will be shifted a different amount. Vigenére cipher The Vigenére cipher is a method to encrypt alphabetic text by using the position of the letter of the input on the key. The key is a word decided by the user and is kept secret. The message cannot be decrypted without the key. Let's encrypt the word "sololearn" with the key "web". Word: sololearn Key: web
  4. Encrypted message: osmwpfwvo The explanation follows: web web web solo learn
  5. Note: Specials characters are not used is this type of cipher. Hashing Hashing means generating value or values from a string of text using a mathematical function. Hashing is one way to enable security during the process of message transmission when the message is intended for a particular recipient only. A formula generates the hash, which helps to protect the security of the transmission against tampering. When a user sends a secure message, a hash of the intended message is generated and encrypted and is sent along with the message. When the message is received, the receiver decrypts the hash as well as the message. Then, the receiver creates another hash from the message. If the two hashes are identical when compared, then a secure transmission has occurred. This hashing process ensures that an unauthorized end user does not alter the message.
  6. Here is a small example in Python that encrypts "Hello World" in SHA-I (Secure Hashing Algorithm): import hashlib hash_object = hashlib.shal (blHello World) hex_dig = hash_object.hexdigest() print(hex_dig) OUTPUT Oa4d55a8d778e5022fab701977c5d840bbc486 You will get a long string which is hashed by the SHA-I algorithm. Note: Hashing is used to index and retrieve items in a database because it is easier to find the item using the shortened hashed key than by using the original value. Salted Passwords In the previous lesson, explained what a hashing, hash function is still vulnerable. Let's imagine that a hacker compiles a list of the million most common passwords. He operates on all the million of them with the hash function and stores the results. Now, the hacker steals a list of hash values stored in the database. He compares that list with his list of encrypted possible passwords and discovers possible matches. This is called a dictionary attack.
  7. Salt is a way to make it more difficult. Salt is a random string that is concatenated with the password before hashing it. Both the salt value and the result of the hash function are stored in the database on the host. If the number of possible salt values is large enough, this practically eliminates a dictionary attack against commonly used passwords because the hacker has to generate the one-way hash for each possible salt value. Note: Salt only protects against general dictionary attacks on a password file, not against a concerted attack on a single password. It protects people who have the same password on multiple machines but doesn't make poorly chosen passwords any better. Methods of Encryption Symmetric encryption Symmetric-key algorithms are algorithms for cryptography that use the same cryptographic keys for both encryption of plaintext and decryption of ciphertext. Both parties are required to have access to the secret key, so this is one of the main drawbacks of symmetric key encryption. Asymmetric encryption Asymmetric cryptography (or public-key cryptography) is any cryptographic system that uses
  8. pairs of keys: public keys which may be disseminated widely, and private keys which are known only to the owner. This accomplishes two functions: authentication, where the public key verifies that a holder of the paired private key sent the message, and encryption, where only the paired private key holder can decrypt the message encrypted with the public key. Note: Hash functions also used in many cryptographic systems. AES (Advanced Encryption Standard) The Advanced Encryption Standard, or AES, is a symmetric block cipher chosen by the U.S. government to protect classified information and is implemented in software and hardware throughout the world to encrypt sensitive data. NIST (The National Institute of Standards and Technology) specified that the new advanced encryption standard algorithm must be a block cipher capable of handling 128 bit blocks, using keys sized at 1 28, 192, and 256 bits. Other criteria for being chosen as the next advanced encryption standard algorithm included security, implementation and cost. Intended to be released under a royalty-free basis, the candidate algorithms were to be evaluated on computational and memory efficiency.
  9. AES comprises three block ciphers: AES-128, AES-192 and AES-256. Each cipher encrypts and decrypts data in blocks of 128 bits using cryptographic keys of 128-, 192-, and 256-bits, respectively. 128 bit t92 bit bit 128 bit AES Design Secret Key Plain Text Cipher Cipher Text Symmetric ciphers use the same key for encrypting and decrypting, so the sender and the receiver must both know (and use) the same secret key. There are 10 rounds for 1 28-bit keys, 12 rounds for 1 92-bit keys, and 14 rounds for 256-bit keys. A round consists of several steps including substitution, transposition, mixing of the input plain text, and transforming it into the final output of cipher text. For example, the "Hello, world!" encrypted in AES-128 is "AOuS61 UOLrJOfnXs04HCgg==" Note: at the end of the encrypted string sign means that we got base64 output.
  10. B's public key B's private key plaintext encryption decryption ciphertext plaintext Public key algorithms are fundamental security ingredients in cryptosystems, applications, and protocols. Some encryption schemes can be proven secure on the basis of the presumed difficulty of a mathematical problem, such as factoring the product of two large primes or computing discrete logarithms. Some examples of asymmetric key encryption: - Diffie-Hellman key exchange protocol - DSS (Digital Signature Standard) - Various password-authenticated key agreement techniques - RSA encryption algorithm Note: Asymmetric key encryption is more secure than symmetric, because you can share your public key as necessary and keep your private key secret. But symmetric algorithms are faster,
  11. so that's why the two types are almost always used together. Cryptography Terminology Plaintext - a clear text message. Encryption - the process of turning a clear-text message (plaintext) into a data stream which looks like a meaningless and random sequence of bits (ciphertext). Decryption - the process of getting plaintext from encrypted data. Cipher - a cryptographic algorithm that uses a mathematical function which takes plaintext as the input and produces ciphertext as the output and vice versa. Ciphertext - the result of encryption performed on plaintext using an algorithm called a cipher.
  12. Key - a cryptographic key is a string of bits used by a cryptographic algorithm to transform plain text into cipher text or vice versa. Stream ciphers - symmetric algorithms that operate on 1 bit (or sometimes 1 byte) of plaintext at a time. Block ciphers - algorithms that operate on blocks of bits at a time. Symmetric algorithms - algorithms that use the same key for encryption and decryption. Public-key (Asymmetric) algorithms - algorithms that use two different keys (public and private) for encryption and decryption.