Sunteți pe pagina 1din 5

BANGALORE INSTITUTE OF TECHNOLOGY

COMPUTER SCIENCE DEPARTMENT

PROJECT : A ROUTING-DRIVEN KEY


MANAGEMENT SCHEME FOR HETEROGENEOUS
SENSOR NETWORKS
Report

Project Guide: Madhuri.J

Project Group: Prashanth.V 1bi07cs079


Chandan.R 1bi07cs021
Darshan.B.H 1bi07cs026
Karthik.G.R 1bi05cs119
DATA ENCRYPTION STANDARD

DES is the block cipher — an algorithm that takes a fixed-length string of


plaintext bits and transforms it through a series of complicated operations
into another ciphertext bitstring of the same length. In the case of DES, the
block size is 64 bits. DES also uses a key to customize the transformation, so
that decryption can supposedly only be performed by those who know the
particular key used to encrypt. The key ostensibly consists of 64 bits
however, only 56 of these are actually used by the algorithm. Eight bits are
used solely for checking parity, and are thereafter discarded. Hence the
effective key length is 56 bits, and it is never quoted as such. Every 8th bit
of the selected key is discarded, i.e. positions 8, 16, 24, 32, 40, 48, 56, 64 are
removed from the 64 bit key leaving behind only the 56 bit key.

Like other block ciphers, DES by itself is not a secure means of encryption
but must instead be used in a mode of operation. FIPS-81 specifies several
modes for use with DES

The algorithm's overall structure there are 16 identical stages of processing,


termed rounds. There is also an initial and final permutation, termed IP and
FP, which are (IP "undoes" the action of FP, and vice versa). IP and FP have
almost no cryptographic significance, but were apparently included in order
to facilitate loading blocks.

Before the main rounds, the block is divided into two 32-bit halves and
processed alternately this criss-crossing is known as the Feistel scheme. The
Feistel structure ensures that decryption and encryption are very similar
processes — the only difference is that the subkeys are applied in the reverse
order when decrypting. The rest of the algorithm is identical. This greatly
simplifies implementation, particularly in hardware, as there is no need for
separate encryption and decryption algorithms.
[Algorithm for the data encryption standard]
algorithm DES

call DES()

end call

[function to encrypt the data]


String encrypt(String msg,String key)

try

if key.length equal to 8

[get the instance of des and place it in cipher]


Cipher cipher<- Cipher.getInstance("DES")

[get new secret key specification of des place in spec]


SecretKeySpec spec<- new SecretKeySpec(key.getBytes()
"DES");

[initialize the cipher text to encrypt mode]


cipher.init(Cipher.ENCRYPT_MODE, spec)

[get the cipher text and place in array]


byte messageArray[]<-msg.getBytes("UTF8");
messageArray<-
cipher.doFinal(messageArray,0,messageArray.length)

[call the inbuilt function BASE64encoder to encrypt the


cipher text]
msg=new BASE64Encoder().encode(messageArray)

end try

catch(Exception e)
[print the exception e if any]
System.out.println(e)
End catch

[return the message]


return msg
end call

[function call to decrypt the cipher text]


String decrypt(String msg,String key)

[init Boolean value to true]


boolean invalid<-true

try

[get the instance of des and place it in cipher]


Cipher cipher<- Cipher.getInstance("DES")

[get new secret key specification of des place in spec]


SecretKeySpec spec= new SecretKeySpec(key.getBytes(), "DES")

[initialize the cipher text to decrypt mode]


cipher.init(Cipher.DECRYPT_MODE, spec)

[call the inbuilt function BASE64Decoder to drcrypt]


byte messageArray[]=new BASE64Decoder().decodeBuffer(msg)
messageArray= cipher.doFinal(messageArray)
msg=""

for all i from 0 to i<messageArray.length


[get the elements of the message array]
msg+=(char) messageArray[i]
msg.trim()
[init invalid to false]
invalid=false

end try
catch(Exception e)
[ptint the exception if any]
System.out.println(e)
invalid=true;
[return the decrypted msg]
return msg
end call

S-ar putea să vă placă și