CNS Observation 6 Programs
CNS Observation 6 Programs
D
a string char poirter) toith a valua'Helo
World.The proaiom Should XoR cach
Proqtam
Chasatenin this tring
eiAing with o and
display the
Proqram.
include<stdioh>
#incude <stdib-hz
printf(') Sdput'
Hello Woil d.
write a Cproqram that Contains
with
o value Hello orla'. Tho tor (izo;icen ;itr )
Rroqiam should AND or and Xol
eathchoTacter in this string wth 24 pritf Cc,st2C);
and duplby the resalt -
prite ("yn)
#include<stdio-h
*includ e cloni oh
Aindude <stringh
Aincude < st db h
Vod main C) Dtput
=Hello world; Hlo t o o t l d a .
Charstr[]
Char stT1 L
Char str 2i
int i, len
len = Strlen (str);
forCiz0; i<lens i t ) l v o
("»c)str 1[3)
printf
printf(n":
3) te olova pioqamg to perfosm
Encypherm and decyrhon Using
a) Ceaser cipher:
decsspteo)Sito34on
Import java.io.Buffev Reados
)
SyutomO4-printlnc'lw);
import java io-TOE Xcephion 'y
import java. io .I nput streanReader; ypt (Stringir iot k)
impost jova.UtlScanhery publ Staie Strinq entt
puble dars Ce aser ciphe
Sysitemoutqint
Strinqstr = by.teadine
C):
if CC)
System -but print l"Enter any Sting )
int key = SC- next Tnt (
Sting encrypied - tncpt (st,key);
wy' opayituv klnn yhij bcdef c 26); (c<a)' ie
Coyptedf -key' C=C
de (be
( if
(]ing maiSn Vod Slahe patlic lowevlaw.
(c))s mckes
is
chaacfer cha
) eada 1npud
Stea Recder(aea
Stadie
ffered eo brReadeButfeied
Statie
new Scner Scan
= ppec
Co) Case (charater-is
Sustitaion
Cigko c
lass jublic 1F
ufl*; jova: toport str.Chart
(i = inct
io-K) jaua.inport (inti for
Dogamps ="; ypted String
dec
Cipher:
Subshtution (b) key) iot
(St spt dec string i
stati puble
Vsl. :2x is datcncrypted
a he
echo 0cSting
Cutputoidboot. any Enter
Cchar)c, enruped
t=
m
dasyp import jovo lo*,
ChosC)
icogi< str .lngth import il.*;
for (int imQort jova. io*;
publie clays Hill cphor i new flot 1(;
hart C)) pubu
(r Sts inden f (): Static float C1l1
intie a. new floot C11C3];
=decry gt decy p+b.Char AL totic float C1C] a
Stadie floatC]1b =
decnt
Ted= new float m.
Stoie loat)CJ
dotois'ttc ypr)s Siadie Bufes Rendubr = ferudnew
new Buf
3 Inpud Stream ReaderCsstemin)
fo (int k co,.ks3:
f6ninti oyi<3,i t)
fohl i ntj -0,is3, 'it)
af:1C31 le.ne float C);
bli01 =
stringbufktr.opperd (cha)byteslil);
ektbnst tingBufferto Stng
0;CPL
puole siate vsid main (Stiog axqs C1)t
hrow sEx
byteivCJe phnutqetU O3
Systenout. prínth ('nihaizahon Vecteh oF Hhe Cphe
tencoder. en code li);
6. l'roq1amming
ting mesage "AES sill socks;l3
Riin dael algosithm logicsi liat
key henemtonkqen= key Ghenexato
phomam t.qet Instan Ce
("AEs"),
Lmport javaSeubity.*j Kgen. init (I23);
import javat. Cry phor*,
(42 and a56 brts mnay not be aw ai lable
inport javax -("ypto. spec*;
inport java io-#; specs.Secter keyskey= kçen qene vote key);
puble cdajs AES £ byte C]baw = Skey
qtEncoded);
putblcstaic Stting as Hex (bye burci) SecvetkeySpec=new Secoet keySpec (raw, "AEr);
StNog Buffe Strbuf e newSthing Buefer (buf lengk Ciphe CipheY : Cipher.get Tnstence ("AES);
*2);
inti;
oiphen.init(Cigher. ENCRY PT MODE,Skey Spec);
byte (lencrypted- C'pk dofinal
fon(i-0; icbuf length; i+) (arqslength =-oJresag:
iECGntl bufCil4Oxff) <oxo)sl Systen aut riotin("'ncrypted
str buf.append ("o"); string:"tas
Ciphen. init(cgheDECRYpTMOOE, Heslencny ral
SkeySper);
sthDXÉ,4):
buf-appund (long:to[ring (int) buf[i4 byteciOriginal = ciphen. dofinal Cenc ryted)y
Seton shbuf. to Sthig(3;
public stati c void man (stringc]ara) thsous Sqstemout printhn( oignatring: toijndStringr" +
Excep ton as Hen (origina));