0% found this document useful (0 votes)
2K views37 pages

Nis-Manual Compress

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

Nis-Manual Compress

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

Network and Information System

Name:Rohit B Harshe
Roll No:- 30
Enrollment No:-1801320123

Practical No.1(A)

Aim:- Install and configure antivirus software on system.


Requirements:-
• Computer system with i5 Intel processor having 8 GB RAM and 1 TB Hard-disk
• Quick heal antivirus
• Operating system:- Windows

Steps for installing antivirus:-


• If you purchased the antivirus program from a retail store, insert the CD or DVD into the
computer's disc drive. The installation process should start automatically, with a window
opening to help guide you through the install process.
• If you downloaded the antivirus program on the Internet, find the downloaded file on your
computer. If the downloaded file is a zip file, unzip the file to extract and access the
installation files. Look for a file named setup.exe, install.exe, or something similar,
then double-click that file. The installation process should start, with a window opening to
help guide you through the install process.
• In the installation process window, follow the steps provided to install the antivirus
program. The install process provides recommended options so the antivirus program will
function properly, which in most cases can be accepted as is. The one exception is if the
install process recommends to install any toolbars for Internet browsers or other helpful
programs for your computer. If prompted to install other software with the antivirus
program, uncheck all boxes or decline the install of those extra programs. No additional
programs should be needed for the antivirus program to install and run successfully on
your computer.
• When the install process is complete, close out of the install window.
• If used, remove the CD or DVD from the computer's disc drive.
Conclusion:-
1|Page
Network and Information System

In this practical we study about how to install and configure an antivirus on system

Practical 1(B)

Aim: - Set up operating system update.

Requirements:-
• Computer system with i5 Intel processor having 8 GB RAM and 1 TB Hard-disk
• Operating system:- Windows

Steps for set up operating system update:-


• Open Windows Update by clicking the Start button in the lower-left corner. In the search
box, type Update, and then, in the list of results, click either Windows Update or Check
for updates
• Click the Check for updates button and then wait while Windows looks for the latest
updates for your computer
• If you see a message telling you that important updates are available, or telling you to
review important updates, click the message to view and select the important updates to
download or install
• In the list, click the important updates for more information. Select the checkboxes for
any updates that you want to install, and then click OK
• Click Install updates

Conclusion

Antivirus programs help prevent viruses and spyware from infecting a


computer and therefore are one of the essential software programs each
computer should have running at all times. There are thousands of viruses and
spyware on the Internet, and any one of them can cause damage to personal
files or the computer's operating system.

PRACTICAL NO:- 2ND

Aim:- Perform the backup and restore system


2|Page
Network and Information System

Requirements:-
• Computer system with i5 Intel processor having 8 GB RAM and 1 TB Hard-disk
• Operating system:- Windows

Steps for Backup on windows 10:-


• Back up
There are several ways to back up your PC.
1. Select the Start button, then select Control Panel > System and
Maintenance > Backup and Restore.
2. Do one of the following:
▪ If you've never used Windows Backup before, or recently upgraded your
version of Windows, select Set up backup, and then follow the steps in the
wizard.
▪ If you've created a backup before, you can wait for your regularly scheduled
backup to occur, or you can manually create a new backup by selecting Back
up now.
▪ If you’ve created a backup before, but want to make a new, full backup
rather than updating the old one, select Create new, full backup, and
then follow the steps in the wizard.

Steps for Restore on windows 10:-


If you're missing an important file or folder that you've backed up, here's how to get it back:

1. In the search box on the taskbar, type restore files, and then select Restore your files with File
History.
2. Look for the file you need, then use the arrows to see all its versions.
3. When you find the version you want, select Restore to save it in its original location. To save it
in a different place, right-click Restore, select Restore to, and then choose a new location.
4. Find your backups created on previous versions of Windows
5. If you used Backup and Restore to back up files or create system image backups in previous
versions of Windows, your old backup is still available in Windows 10. In the search box on the
3|Page
Network and Information System

taskbar, type control panel. Then select Control Panel > System and Security > Backup and
Restore (Windows 7).

• Restore files from a file backup after restoring your computer from a system image
backup
After you restore your computer from a system image backup, there may be
newer versions of some of your files in a file backup that you want to restore.

To restore files from a file backup that was created after the system image backup was
created, follow these steps.
1. Select the Start button, then select Control Panel > System and
Maintenance >Backup and Restore.
2. Choose Select another backup to restore files from. If you're prompted
for an administrator password or confirmation, type the password or provide
confirmation.
3. In Backup Period, select the date range of the backup that contains the files that
you want to restore, and then follow the steps in the wizard.

Conclusion
In this practical we learnt about how to perform backup and restore on windows 10.

Practical No.3

Aim: Setup Password to the Operating System and Application


Create a Password in the Control Panel

Assuming you haven't configured Windows to automatically log in, chances are you simply
don't have a password set for your Windows account. You need to correct this by creating
a password right now.

You can make one from Control Panel. Once you have, you must use it to log on to

4|Page
Network and Information System

Windows from that point forward. That is, unless you at some point remove your
Windows password.

The specific steps you need to follow to create a Windows logon password differ somewhat
depending on the operating system you're using. See What Version of Windows Do I
Have? if you're not sure which of those several versions of Windows is installed on your
computer.
It's always a good idea to create a password reset disk after creating a new password. If
your password is really complex and you don't want to make a reset disk, consider storing it
in a password manager.

How to Create a Windows 10 or Windows 8 Password

1. Open Control Panel. The easiest way to do that in Windows 10 is by executing


control from the Start menu or Run dialog box. In Windows 8, use the Power User
Menu by pressing Win+X.

2. Select User Accounts (Windows 10) or User Accounts and Family Safety
(Windows 8).

3. Open User Accounts.


4. Choose Make changes to my account in PC settings.

5. Select Sign-in options from the left.

6. Under the Password area, choose Add.

7. Enter the new password in the first two text fields. You have to do it twice to make
sure you type the password correctly.

8. In the Password hint field, enter something that will help you remember the password
should you forget it, and then select Next.

9. Hit Finish to complete the new password setup.

10. You can now exit out of any windows you opened to make the
password, like Settings or PC settings.

How to Create a Windows 7 or Windows Vista Password

5|Page
Network and Information System

1. Open Control Panel from the Start menu.


2. Select User Accounts and Family Safety (Windows 7) or User Accounts
(Windows Vista).

3. Choose User Accounts.

4. In the Make changes to your user account area, select Create a password for your
account.

5. Type the password you want to use in the first two text boxes.

6. Enter something useful in the Type a password hint text box. This step is optional
but we highly recommend that you use it. If you try logging in to Windows but enter
the wrong password, this hint will pop up, hopefully jogging your memory.

7. Choose Create password to confirm your new password.


8. You can now close out of any open windows you used to reach the page for changing
the password.

How to Create a Windows XP Password

1. Navigate to Start > Control Panel.


2. Choose User Accounts.
If you're in the Category View of Control Panel, you'll need to select it again on
the next screen.

3. Select your username in the, or pick an account to change area.

4. Choose the Create a password link.

6|Page
Network and Information System

5. In the first two text boxes, enter the password you would like to start using.
6. Choose Create Password to confirm your new password.
7. The next screen might ask Do you want to make your files and folders private? . If
other user accounts will be set up on this PC and you'd like to keep your personal
files private, select Yes, Make Private.

If you're not concerned about this kind of security or this account is the only
account on your PC, you can choose No.

8. You can now close the User Accounts window and the Control Panel window.
Conclusion:

Security refers to providing a protection system to computer system resources such as


CPU, memory, disk, software programs and most importantly data/information stored in
the computer system. If a computer program is run by an unauthorized user, then he/she
may cause severe damage to computer or data stored in it. So a computer system must be
protected against unauthorized access, malicious access to system memory, viruses,
worms etc.

Practical No. 4
Aim: Apply security to file folder or application using access permission and
verify.
Steps to Assign File/Folder Permissions

1. Go to “Start Menu” ➔ “Administrative Tools”, and click “Group Policy


Management” to access its console.

2. In left panel of “Group Policy Management Console”, you have to create a new
Group Policy Object or edit an existing Group Policy Object.

3. To create a new GPO, right click “Group Policy Objects”, and select “New” from the
7|Page
Network and Information System

context menu. It shows “New GPO” window.

Figure 1: Creating a new GPO

4. Enter a name for the Group Policy Object (GPO) (in this case it is Assigning Folder
Permissions), leave “Source Starter GPO” as “(none)”.

8|Page
Network and Information System

5. Right-click on the newly created “User Folder Permissions” GPO, and select “Edit
GPO”. Group Policy Management Editor window appears on the screen

6. Navigate to “Computer Configuration” ➔ “Policies” ➔ “Windows Settings”


➔ “Security Settings” ➔ “File System”

Figure 2: Navigate to File System

7. Right-click on “File System” in the left pane and select “Add File…” It shows the
following dialog box

9|Page
Network and Information System

.
Figure 3: Select file or folder which you want to assign permissions on

8. Browse the folder or file that you wish to assign permissions on, and left click to select
it. Click “OK”.

9. “Database Security” window appears on the screen

Figure 4: Database security window

10. Click “Advanced” button to access “Advanced Security Settings” window. Stay on
the “Permissions” tab that appears by default.

10 | P a g e
Network and Information System

Figure 5: Advanced security settings window

11. On this tab, either select an existing user and click “Edit…” or click “Add…”
to add a new user to the permissions.

12. “Permissions Entry for…” dialog box opens up. Here, you will see that there is a
list of permissions available for your users, and you can also choose where you
want to apply those permissions.

11 | P a g e
Network and Information System

Figure 6: Permissions entry folders

13. Use the drop-down menu in the “Apply to” field to assign selected
permissions to desired folders.

14. Check the permissions as needed. These are self-explanatory.


15. Click “OK” to apply the permissions. It takes you back to “Advanced Security”
window.

16. Now, move to the “Auditing” tab. Under this tab, you can do audit settings for the folder,
so that any change done to this folder or its permission will be audited. Configure the
auditing settings as per requirement.

12 | P a g e
Network and Information System

17. Similarly, you can do ownership settings for the folder under “Owner” tab.

18. Once you have done “Permission”, “Auditing” and “Ownership” settings, click
“OK” to close “Advanced Security…” window.

19. Click “OK” to close “Database Security…” window. Next, you will see “Add Object”
window.

Figure 7: Add object window 20.


There are three options on the “Add Object” window:

a. Configure this file or folder then: Select this option to apply the settings. It contains
the following two options.
i. Propagate inheritable permissions to all subfolders and files: Selecting this option
means, all the subfolders and files will inherit permissions from the parent folder. In
case of a mismatch or conflict, explicit permissions that

13 | P a g e
Network and Information System

were assigned to the subfolders or files will override the inherited


permissions.

ii. Replace existing permissions on all subfolders and files with inheritable
permissions: This option will overwrite all the settings on all subfolders and files with
the ones on the parent, so ultimately they will have identical permissions to the parent
folder.

b. Do not allow permissions on this file or folder to be replaced: Use this setting for
subfolders and files that you do not want to inherit permissions. For this, make an
additional entry for those subfolders and files that will not inherit permissions e.g. let’s
say you want the “A” folder to inherit permission but don’t want “B” folder to inherit
permissions, in that case create an entry for the “B” folder.

21. Close “Group Policy Management Editor” window.


22. Right-click the domain you want to apply this GPO to, and then select “Link an
Existing GPO…” option from the context menu. “Select GPO” window opens up

14 | P a g e
Network and Information System

Figure 8: Select the new GPO

23. Select the new “Assigning Folder Permissions” GPO, then click OK.

24. In the right pane, stay on the “Linked Group Policy Objects” tab that appears by
default.

25. Right-click on the “Assigning Folder Permissions”, and select “Enforced” from the
context menu. A confirmation message appears on the screen.

26. Click “OK” to close the dialog box.

Conclusion: Assigning permissions for each file and folder individually can be complex
and time consuming. To avoid going through the annoyances of changing permissions for a
bunch of folders individually, we can use Group Policy to do it. In this article, you will see
the process of assigning file and folder permissions across a domain through GPO. These
instructions can be extremely helpful, and save your time if you have to assign permissions
to a large number of systems with a common setup.

15 | P a g e
Network and Information System

Practical No. 5
Aim: Write a program to implement Caesar Cipher
Introduction:

Algorithm of Caesar Cipher

The algorithm of Caesar cipher holds the following features −

• Caesar Cipher Technique is the simple and easy method of encryption


technique.

• It is simple type of substitution cipher.

• Each letter of plain text is replaced by a letter with some fixed number of positions
down with alphabet.

The following diagram depicts the working of Caesar cipher algorithm


implementation −

16 | P a g e
Network and Information System

Explanation

The plain text character is traversed one at a time.


• For each character in the given plain text, transform the given character as per the
rule depending on the procedure of encryption and decryption of text.

• After the steps is followed, a new string is generated which is referred as cipher
text.

Feature of Caesar Cipher Algorithm

This algorithm consists of a few features that are given below. o This technique is quite
simple to apply encryption. o Each text is replaced by the fixed number of position
down or up with the alphabet. o It is a simple type of substitute cipher.

There is an integer value required to define each latter of the text that has been moved
down. This integer value is also known as the shift.

We can represent this concept using modular arithmetic by first transmuting the letter
into numbers, according to the schema, A = 0, B = 1, C = 2, D = 3 Z = 25.

The following mathematical formula can be used to shift n letter.

The program implementation of Caesar cipher algorithm is as follows –

17 | P a g e
Network and Information System

Program:
#A python program to illustrate
Caesar Cipher Technique
def encrypt(text,s):
result = ""

# traverse text
for i in range(len(text)):
char = text[i]

# Encrypt uppercase characters


if (char.isupper()):
result += chr((ord(char)
+ s-65) % 26 + 65)

# Encrypt lowercase characters


else:
result += chr((ord(char)
+ s - 97) % 26 + 97)

return result

#check the above function


text = "ATTACKATONCE"
s=4
print ("Text : " + text)
print ("Shift : " + str(s))
print ("Cipher: " + encrypt(text,s))

18 | P a g e
Network and Information System

Output:

Conclusion:

The Caesar Cipher technique is one of the earliest and simplest method of encryption
technique. It’s simply a type of substitution cipher, i.e., each letter of a given text is
replaced by a letter some fixed number of positions 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
apparently named after Julius Caesar, who apparently used it to communicate with his
officials.

Thus to cipher a given text we need an integer value, known as shift which indicates the
number of position each letter of the text has been moved down

Practical No. 6
Aim: Write a program to implement Vernam
Cipher

19 | P a g e
Network and Information System

Introduction:

Vernam Cipher in Cryptography

Vernam Cipher is a method of encrypting alphabetic text. It is one of the Transposition


techniques for converting a plain text into a cipher text. In this mechanism we assign a
number to each character of the Plain-Text, like (a = 0, b = 1, c = 2, … z = 25).

Method to take key:


In Vernam cipher algorithm, we take a key to encrypt the plain text which length should be
equal to the length of the plain text.

Encryption Algorithm:

1. Assign a number to each character of the plain-text and the key according to
alphabetical order.

2. Add both the number (Corresponding plain-text character number and Key character
number()

20 | P a g e
Network and Information System

3. Subtract the number from 26 if the added number is greater than 26, if it isn’t then
leave it.

Example:
Plain-Text: RAMSWARUPK
Key: RANCHOBABA

Now according to our encryption algorithm we assign a number to each character of our
plain-text and key.

PT: R A M S W A R U P K

NO: 17 0 12 18 22 0 17 20 15 10

KEY: R A N C H O BAB A

NO: 17 0 13 2 7 14 1 0 1 0

Now add the number of Plain-Text and Key and after doing the addition and subtraction
operation (if required), we will get the corresponding Cipher-Text character number.

CT-NO: 34 0 25 20 29 14 18 20 16 10

In this case, there are two numbers which are greater than the 26 so we have to subtract 26
from them and after applying the subtraction operation the new Cipher text character
numbers are as follow:

21 | P a g e
Network and Information System

CT-NO: 8 0 25 20 3 14 18 20 16 10

New Cipher-Text is after getting the corresponding character from the number.

CIPHER-TEXT: I A Z U D O S U Q K

Program:
# Vernam cypher demo
# T Street 2015-10-16

def makeVernamCypher( text, key ):


""" Returns the Vernam Cypher for given string and key """
answer = "" # the Cypher text
p = 0 # pointer for the key
for char in text:
answer += chr(ord(char) ^ ord(key[p]))
p += 1
if p==len(key):
p=0
return answer

MY_KEY = "cvwopslweinedvq9fnasdlkfn2"
while True:
print("\n\n---Vernam Cypher---")
PlainText = input("Enter text to encrypt: ")
# Encrypt
Cypher = makeVernamCypher(PlainText, MY_KEY)
print("Cypher text: "+Cypher)
# Decrypt
decrypt = makeVernamCypher(Cypher, MY_KEY)
print("Decrypt: "+decrypt)

Output:

22 | P a g e
Network and Information System

Conclusion:

The Vernam cipher is, in theory, a perfect cipher. Instead of a single key, each plaintext
character is encrypted using its own key. This key -- or key stream — is randomly
generated or is taken from a one-time pad, e.g. a page of a book. The key must be equal in
length to the plaintext message. The fact that each character of the message is encrypted
using a different key prevents any useful information being revealed through a frequency
analysis of the ciphertext

23 | P a g e
Network and Information System

Practical No. 7

Aim: Create and Verify Hash Code for given message.

Introduction:
A hash function is a function that takes input of a variable
length sequence of bytes and converts it to a fixed length sequence. It is a one way
function. This means if f is the hashing function, calculating f(x) is pretty fast and simple,
but trying to obtain x again will take years. The value returned by a hash function is often
called a hash, message digest, hash value, or checksum. Most of the time a hash function
will produce unique output for a given input. However depending on the algorithm, there is
a possibility to find a collision due to the mathematical theory behind these functions.

Now suppose you want to hash the string "Hello Word" with the SHA1 Function, the result is
0a4d55a8d778e5022fab701977c5d840bbc486d0.

Hash functions are used inside some cryptographic algorithms, in digital signatures,
message authentication codes, manipulation detection, fingerprints, checksums (message
integrity check), hash tables, password storage and much more. As a Python programmer
24 | P a g e
Network and Information System

you may need these functions to check for duplicate data or files, to check data integrity
when you transmit information

over a network, to securely store passwords in databases, or maybe some work related to
cryptography.

Program:
#hash for integer unchanged

>>> print('Hash for 181 is:',hash(181)) #hash


for decimal
>>> print('Hash for 181.23 is:',hash(181.23)) #hash
for string
>>> print('Hash for Python is:',hash('Python'))

Output:

Conclusion:

Hash method in Python is a module that is used to return the hash value of an object. In
programming, the hash method is used to return integer values that are

25 | P a g e
Network and Information System

used to compare dictionary keys using a dictionary look up feature. When used, it calls for
the hash () of an object which is set by default during the creation of the
object by the user.

Practical No. 8
Aim: Write a program to implement Rail fence technique.
Introduction:

Rail- fence cipher is a transposition cipher that encrypts the plain text by
changing the position of each character.

This cipher takes an input string and a key and arranges the letters in the string in a
diagonal fashion. For implementing Rail-fence Cipher in Python, a rectangular grid is
required with the number of rows corresponding to the key, and the number of columns
corresponding to the length of string to be encrypted. Then the ciphertext is generated by
reading the resultant grid row by row.
For example

Here, The number of rows in the grid = key = 4


26 | P a g e
Network and Information System

The number of columns in the grid= length of plain text = 10

Program:
# Python3 program to illustrate
# Rail Fence Cipher Encryption
# and Decryption

# function to encrypt a message


def encryptRailFence(text, key):

# create the matrix to cipher


# plain text key = rows ,
# length(text) = columns
# filling the rail matrix
# to distinguish filled
# spaces from blank ones
rail = [['\n' for i in range(len(text))]
for j in range(key)]

# to find the direction


dir_down = False
row, col = 0, 0

for i in range(len(text)):

# check the direction of flow


# reverse the direction if we've just
# filled the top or bottom rail
if (row == 0) or (row == key - 1):
dir_down = not dir_down

# fill the corresponding alphabet


rail[row][col] = text[i]
col += 1

# find the next row using


# direction flag
if dir_down:

27 | P a g e
Network and Information System

row += 1
else:
row -= 1
# now we can construct the cipher
# using the rail matrix
result = []
for i in range(key):
for j in range(len(text)):
if rail[i][j] != '\n':
result.append(rail[i][j])
return("" . join(result))

# This function receives cipher-text


# and key and returns the original
# text after decryption
def decryptRailFence(cipher, key):

# create the matrix to cipher


# plain text key = rows ,
# length(text) = columns
# filling the rail matrix to
# distinguish filled spaces
# from blank ones
rail = [['\n' for i in range(len(cipher))]
for j in range(key)]

# to find the direction


dir_down = None
row, col = 0, 0

# mark the places with '*'


for i in range(len(cipher)):
if row == 0:
dir_down = True
if row == key - 1:
dir_down = False

# place the marker


rail[row][col] = '*'
28 | P a g e
Network and Information System

col += 1

# find the next row


# using direction flag
if dir_down:
row += 1
else:
row -= 1

# now we can construct the


# fill the rail matrix
index = 0
for i in range(key):
for j in range(len(cipher)):
if ((rail[i][j] == '*') and
(index < len(cipher))):
rail[i][j] = cipher[index]
index += 1

# now read the matrix in


# zig-zag manner to construct
# the resultant text
result = []
row, col = 0, 0
for i in range(len(cipher)):

# check the direction of flow


if row == 0:
dir_down = True
if row == key-1:
dir_down = False

# place the marker


if (rail[row][col] != '*'):
result.append(rail[row][col])
col += 1

# find the next row using


# direction flag
29 | P a g e
Network and Information System

if dir_down:
row += 1
else:
row -= 1
return("".join(result))

# Driver code
if __name__ == "__main__":
print(encryptRailFence("attack at once", 2))
print(encryptRailFence("GeeksforGeeks ", 3))
print(encryptRailFence("defend the east wall", 3))

# Now decryption of the


# same cipher-text
print(decryptRailFence("GsGsekfrek eoe", 3))
print(decryptRailFence("atc toctaka ne", 2))
print(decryptRailFence("dnhaweedtees alf tl", 3))

Output:

30 | P a g e
Network and Information System

Conclusion:
In the rail fence cipher, the plaintext is written downwards diagonally on successive
"rails" of an imaginary fence, then moving up when the bottom rail is reached, down
again when the top rail is reached, and so on until the whole plaintext is written out. The
cipher text is then read off in rows.

Practical No. 9
Aim: Write a program to implement Simple Columnar transposition Technique

Introduction:

The Columnar Transposition rearranges the plaintext letters, based on a matrix filled with
letters in the order determined by the secret keyword.

The Columnar Transposition is a simple transposition cipher that can be performed


manually, without the need of using additional equipment. It was very popular throughout
centuries, and it was used in various situations by diplomats, soldiers, and spies.

The encryption and decryption can be performed by hand, using a piece of paper and a
31 | P a g e
Network and Information System

simple matrix, into which the user enters the letters of the message.

Example:

A simple example for a transposition cipher is columnar transposition cipher where each
character in the plain text is written horizontally with specified alphabet width. The cipher
is written vertically, which creates an entirely different cipher text.

Consider the plain text hello world, and let us apply the simple columnar transposition
technique as shown below

The plain text characters are placed horizontally and the cipher text is created with vertical
format as : holewdlo lr. Now, the receiver has to use the same table to decrypt the cipher
text to plain text.

32 | P a g e
Network and Information System

Program:

# Python3 implementation of
# Columnar Transposition
import math

key = "HACK"

# Encryption
def encryptMessage(msg):
cipher = ""

# track key indices


k_indx = 0

msg_len = float(len(msg))
msg_lst = list(msg)
key_lst = sorted(list(key))

# calculate column of the matrix


col = len(key)

# calculate maximum row of the matrix


row = int(math.ceil(msg_len / col))

# add the padding character '_' in empty


# the empty cell of the matix
fill_null = int((row * col) - msg_len)
msg_lst.extend('_' * fill_null)

# create Matrix and insert message and


# padding characters row-wise
matrix = [msg_lst[i: i + col]
for i in range(0, len(msg_lst), col)]

# read matrix column-wise using key

33 | P a g e
Network and Information System

for _ in range(col):
curr_idx = key.index(key_lst[k_indx])
cipher += ''.join([row[curr_idx]
for row in matrix])
k_indx += 1

return cipher

# Decryption
def decryptMessage(cipher):
msg = ""

# track key indices


k_indx = 0

# track msg indices


msg_indx = 0
msg_len = float(len(cipher))
msg_lst = list(cipher)

# calculate column of the matrix


col = len(key)

# calculate maximum row of the matrix


row = int(math.ceil(msg_len / col))

# convert key into list and sort


# alphabetically so we can access
# each character by its alphabetical position.
key_lst = sorted(list(key))

# create an empty matrix to


# store deciphered message
dec_cipher = []
for _ in range(row):
dec_cipher += [[None] * col]

# Arrange the matrix column wise according


# to permutation order by adding into new matrix
34 | P a g e
Network and Information System

for _ in range(col):
curr_idx = key.index(key_lst[k_indx])

for j in range(row):
dec_cipher[j][curr_idx] = msg_lst[msg_indx]
msg_indx += 1
k_indx += 1

# convert decrypted msg matrix into a string


try:
msg = ''.join(sum(dec_cipher, []))
except TypeError:
raise TypeError("This program cannot",
"handle repeating words.")

null_count = msg.count('_')

if null_count > 0:
return msg[: -null_count]

return msg

# Driver Code
msg = "Geeks for Geeks"

cipher = encryptMessage(msg)
print("Encrypted Message: {}".
format(cipher))

print("Decryped Message: {}".


format(decryptMessage(cipher)))

35 | P a g e
Network and Information System

Output:

Conclusion:
Transposition Cipher is a cryptographic algorithm where the order of alphabets in the
plaintext is rearranged to form a cipher text. In this process, the actual plain text alphabets
are not included. In cryptography, a transposition cipher is a method of encryption by which
the positions held by units of plaintext (which are commonly characters or groups of
characters) are shifted according to a regular system, so that the cipher text constitutes a
permutation of the plaintext. That is, the order of the units is changed (the plaintext is
reordered).
Mathematically a bijective function is used on the characters' positions to encrypt
and an inverse function to decrypt.

36 | P a g e
Network and Information System

37 | P a g e

You might also like