留学生C /C #/Java/y thon /M A T L A B辅导讲解、讲解Java设计、Java语言解析

- 首页 >> Java编程

You can write in C /C #/Java/y thon /M A T L A B , etc.




1 .Substituti on Ciphers


I n Sub stitution ci pher, each l etter i n th e p l ai n text is repl aced b y  a l etter h av i ng so m e f ixed number of posi ti on s do w n /o r up th e al ph ab et.


?E x am p l e:




P l ease implement E n cry p t(Letter, Key ) and Decry p t(Letter, Key ). Key is the input parameter, which can b e def ined b y  users. F o r ex am p l e, w h en K ey = 3,

Encrypt(“HELLO”,3) = “KHOOR”, and  Decrypt(“KHOOR”,3) = “HELLO”. Key  can  be other values.


2..T ran sp o si ti on C i p h er


In transposition cipher, the message is encrypted by rearrnaging the letter order, i .e., w ri te l etters ou t d i ag on al l y o v er a nu m b er o f ro w s, th en read o f f ci ph er ro w b y ro w . F o r example, the  plain text “meet after  the  toga party”, can be written  out  as:


?m  e m  a t r h t g p r y


?e t   e f e t e o a a t


i f th e ci ph er tex t i s w ri tten i n tw o ro w s.


P l ease i m p l em en t E n cry p t(L etter, K ey ) and D ecry p t(L etter, K ey ), w i th K ey  as ho w  m an y ro w s are th ere i n ci ph er tex t.




3.P rodu ct C i p h ers


W  e d ef i n e P rodu ct C i p h er as th e F un cti o n o f B o o l ean al g eb ra: tw o b i ts are co m p ared . I f tw o b i ts are i d en ti cal , th e resu l t i s b i n ary  0; I f tw o b i ts are n o t i d en ti cal , th e resu l t i s

b i n ary 1 , sho w n as i n th e f o l l o w i ng f i g u re.




P l ease i m p l em en t E n cry p t(Letter, Key ) and Decry p t(Letter, Key ), with K ey  as d ef i n ed b y users.


站长地图