Showing posts with label Cryptography. Show all posts
Showing posts with label Cryptography. Show all posts
Reversible crypto system using XOR logical gate
How to create a reversible crypto system using XOR logical gate ?
We have various logical operators like OR, AND etc. Among them XOR can be implemented easily and can be understood.
XOR hasthe following advantages when used for cryptography:
We have various logical operators like OR, AND etc. Among them XOR can be implemented easily and can be understood.
XOR hasthe following advantages when used for cryptography:
- Very fast computable, especially in hardware.
- Not making a difference between the right and left site. (Being commutative.)
- It doesn't matter how many and in which order you XOR values. (Being associative.)
- Easy to understand and analyse.
When we are implementing Xor, the secret key should be having the length equal to the plain text.
------------------------------------------------------------------------------------------------------------------------
XOR Encryption Decryption :
def EncryptionDecryption(input,key):
output = []
for i in range(len(input)):
xor_num = ord(input[i]) ^ ord(key[i])
output.append(chr(xor_num))
return ''.join(output)
def main():
plainText = input ("Enter Plain Text :")
SecretKey = input ("Enter Secret Key :")
encrypted = encryptDecrypt(plainText,SecretKey);
print("Encrypted:"+encrypted);
decrypted = encryptDecrypt(encrypted,SecretKey);
print("Decrypted:"+decrypted);
if __name__ == '__main__':
main()
--------------------------------------------------------------------------------------------------------------------------
Randomness in Cryptography
Randomness in Cryptography :
- System designers are typically more concerned with the power consumption and bit generation speed, than with the actual randomness of the bits generated
- cryptographic systems, the quality of the random numbers used directly determines the security strength of the system.
- the quality of the random number generator directly influences how difficult it is to attack the system
- modern cryptographic algorithms and protocols are designed around a well-known principle by Kerckhoff, which roughly translates into the statement that "The security of the system must depend solely on the key material, and not on the design of the system."
- This means that all modern security algorithms and protocols have their ‘cryptographic strength’ expressed in the number of (key) bits that an attacker needs to guess before he can break the system1 . This expression of strength implicitly assumes that the attacker has no knowledge of the bits of the original key used. The ‘effective strength’ of an algorithm is diminished when better attacks against it are found a
Message Digest
Message Digest :
Reference :
https://www.techopedia.com/definition/4024/message-digest
A message digest is a cryptographic hash function containing a string of digits created by a one-way hashing formula.
Message digests are designed to protect the integrity of a piece of data or media to detect changes and alterations to any part of a message. They are a type of cryptography utilizing hash values that can warn the copyright owner of any modifications applied to their work.
Message digest hash numbers represent specific files containing the protected works. One message digest is assigned to particular data content. It can reference a change made deliberately or accidentally, but it prompts the owner to identify the modification as well as the individual(s) making the change. Message digests are algorithmic numbers.
This term is also known as a hash value and sometimes as a checksum.Reference :
https://www.techopedia.com/definition/4024/message-digest
Substitution and Transposition Ciphers
Substitution and Transposition Ciphers :
Substitution Cipher :
In the plain text, each character is replaced by exactly one other character.Mono alphabetic and Poly alphabetic are the two types of Substitution Ciphers
Transposition Cipher :
The order of the characters is rearranged but does not change the actual characters. Keyless and Keyed are the two types of Transposition Ciphers.
Substitution Cipher :
In the plain text, each character is replaced by exactly one other character.Mono alphabetic and Poly alphabetic are the two types of Substitution Ciphers
Transposition Cipher :
The order of the characters is rearranged but does not change the actual characters. Keyless and Keyed are the two types of Transposition Ciphers.
Stream Cipher & Block Cipher
Stream Cipher:
Block Cipher:
- Plain Text is decoded as and when the data is being received.
Block Cipher:
- Plain Text is divided in to blocks .The length of the block depends on the size of the Key
Playfair Cipher
- Has a key that is filled in the matrix form .If the Key has repeated words,then from the other that first time it is neglected while filling the matrix.
- From the plain text,Certain rules are followed to decode it.
- Then apply the following 4 rules, in order, to each pair of letters in the plain text:
- If both letters are the same (or only one letter is left), add an "X" after the first letter. Encrypt the new pair and continue. Some variants of Playfair use "Q" instead of "X", but any letter, itself uncommon as a repeated pair, will do.
- If the letters appear on the same row of your table, replace them with the letters to their immediate right respectively (wrapping around to the left side of the row if a letter in the original pair was on the right side of the row).
- If the letters appear on the same column of your table, replace them with the letters immediately below respectively (wrapping around to the top side of the column if a letter in the original pair was on the bottom side of the column).
- If the letters are not on the same row or column, replace them with the letters on the same row respectively but at the other pair of corners of the rectangle defined by the original pair. The order is important – the first letter of the encrypted pair is the one that lies on the same row as the first letter of the plaintext pair.
Reference:
Vigenère Cipher
- It uses the Matrix with rows and columns with the indices as alphabets in alphabetical order.
- There is a Key which points to a particular alphabet .This key is used to generate Cipher Text from the Plain Text
- From that key each word in the plain text is decoded such a way that the row alphabets corresponds to the plain text alphabets and matches to the Key word in the Column alphabets.
Drawbacks:
- Text Frequency analysis can be used to recover the plain text from cipher text.
Reference:
http://www.cs.mtu.edu/~shene/NSF-4/Tutorial/VIG/Vig-Base.html
Cryptography
Cryptography:
One of the most important things in our daily lives is to communicate with each other.We communicate to gain knowledge or share our knowledge. Some times the information we need to share the information secretly through a medium of communication, for example through telegram.
Cryptography is defined as encoding the original information in some form so that the third person cannot know the details when a message is to be send between two people.
Caeser Shift Cipher: Here the alphabets are shifted by a desired number, after that they are mapped to their respective values.The original message is encoded based on the values of the alphabets.
Steganography: Here after encoding the original message ,the sender also wants to make sure that the encoded message is not visible to the third person.Example : watermarks
Goals of cryptograhy:
Confidentiality: Keeps the information secure from unauthorised person.
Data Integrity: If any one makes changes in the encoded code,at the end the receiver should be able to retrieve the original information.
Authentication:
Non-repudiation: Once the message is set to be send to a particular person,it need to be accepted abd cannot be rejected.
Types of Cryptosystems:
Symmetric Key Encryption: Sender and Reciever has same to encrypt and decrypt
Asymmetric Key Encryption: Sender and Reciever donot have the same key.
Attacks are classified as follows:
Passive: Accessing the information the transmission medium without having the authentication right.
Active : Changing the information in some way by conducting some process on the information.
Earlier Cryptographic Systems:
Caesar Cipher: Shifting the letters.
Simple Substitution Cipher:
Monoalphabetic Cipher: Substitution cipher in which for a given key, the cipher alphabet for each plain alphabet is fixed throughout the encryption process
Polyalphabetic Cipher: Substitution cipher in which the cipher alphabet for the plain alphabet may be different at different places during the encryption process.
Modern Symmetric Key Encryption:
Block Ciphers
Stream Ciphers
One of the most important things in our daily lives is to communicate with each other.We communicate to gain knowledge or share our knowledge. Some times the information we need to share the information secretly through a medium of communication, for example through telegram.
Cryptography is defined as encoding the original information in some form so that the third person cannot know the details when a message is to be send between two people.
Caeser Shift Cipher: Here the alphabets are shifted by a desired number, after that they are mapped to their respective values.The original message is encoded based on the values of the alphabets.
Steganography: Here after encoding the original message ,the sender also wants to make sure that the encoded message is not visible to the third person.Example : watermarks
Goals of cryptograhy:
Confidentiality: Keeps the information secure from unauthorised person.
Data Integrity: If any one makes changes in the encoded code,at the end the receiver should be able to retrieve the original information.
Authentication:
Non-repudiation: Once the message is set to be send to a particular person,it need to be accepted abd cannot be rejected.
Types of Cryptosystems:
Symmetric Key Encryption: Sender and Reciever has same to encrypt and decrypt
Asymmetric Key Encryption: Sender and Reciever donot have the same key.
Attacks are classified as follows:
Passive: Accessing the information the transmission medium without having the authentication right.
Active : Changing the information in some way by conducting some process on the information.
Earlier Cryptographic Systems:
Caesar Cipher: Shifting the letters.
Simple Substitution Cipher:
Monoalphabetic Cipher: Substitution cipher in which for a given key, the cipher alphabet for each plain alphabet is fixed throughout the encryption process
Polyalphabetic Cipher: Substitution cipher in which the cipher alphabet for the plain alphabet may be different at different places during the encryption process.
Modern Symmetric Key Encryption:
Block Ciphers
Stream Ciphers
Subscribe to:
Posts
(
Atom
)