Sei sulla pagina 1di 8

Data Compression &

Encryption

Introduction
Data compression is a process by which the file size is reduced by re-encoding the
file data to use fewer bits of storage than the original file. The original file can then be
recreated from the compressed representation using a reverse process called
decompression. There are several different algorithms and implementations that allow
you to compress your files, some of which perform better than others for certain kinds of
file types.

Data Encryption is the conversion of electronic data into another form, called
ciphertext, which cannot be easily understood by anyone except authorized parties.
The primary purpose of encryption is to protect the confidentiality of digital data stored on
computer systems or transmitted via the Internet or other computer networks. Modern
encryption algorithms play a vital role in the security assurance of IT systems and
communications as they can provide not only confidentiality, but also the following key
elements of security

Types of Compression

Data compression

Encryption & Decryption

Algorithm for Data compression


1. Determine the count of each symbol in the input message.
2. Create a forest of single-node trees. Each node in the initial forest represents a symbol
from the set of possible symbols, and contains the count of that symbol in the message
to be coded. Symbols with a count of zero are ignored (consider them to be impossible).
3. Loop while there is more than 1 tree in the forest:

3a. Remove the two trees from the forest that have the lowest count contained in their
roots.

3b. Create a new node that will be the root of a new tree. This new tree will have
those two trees just removed in step 3a as left and right subtrees. The count in the root
of this new tree will be the sum of the counts in the roots of its subtrees. Label the edge
from this new root to its left subtree 1, and label the edge to its right subtree 0.

3c. Insert this new tree in the forest, and go to 2.

4. Return the one tree in the forest as the Huffman code tree.


Algorithm for Data Encryption

1. Scan the Message/Text.


2. Generate a random key for the whole text.
3. Shift the characters of the message according to the random key
generated.
4. Save the key.
5. Send the Encrypted message.

Pseudocode for Compression,Encryption & Decryption

int i=0;
while (i < total number of character to transmit)
{if(data(i)!=data(i+1) do ; if this point is not like the next point
{transmit(data(i)+128) ; set bit 7 and transmit
i=i+1 ; increment pointer
}ENDDO
ELSE
{count=i+1 ; count-i is the repeat count
WHILE ((data(i)=data(count) AND (count-i<127)) DO
{count=count+1; increment counter
} ENDDO
count=count-i
; repeat count
transmit(count) ; send repeat count with bit7=0
transmit(data(i)) ; send character
i=count+1 ; point to next character
}ENDIF
}ENDWHILE

Potrebbero piacerti anche