Working with crypto Graphy

Working with crypto Graphy:-

1.Cryptography is a Concept of data encryptions and decryptions.

1. Converting actual data into some another format is called as “encryption” and rice verla is called as “Decryption”.
2. To encrypt or decrypt some logic is required which is called as an algorithm.
3. C#.NET supports ~65000*65000 types of algorithms every algorithm will be identified with unique 6 Byte value.
4. C# recommends to encrypt or decrypt the data in two levels.

Syntax to write a 16 Byte Array value

byte[]X=new byte[] 0x23,0x21,0x90……}

There 16 Values must be in the range of 0x100 to 0x99

0 work with cryptography, .NET introduced ripple des crypto service provider class, which is the part of system. Security. Crypto graphy name space.

Example on cryptography:-

A Program to store encrypted data in a text file and reading that data by decryption

Open WFAP

Place two buttons as shown

Using system. Security. cryptography;

Using system.I0;//When ever we need to write in a text file this name space is required.

Code in GD[Before button1]

Code in GD[Before button1]

Triple Descript to service proricler t = new triple descript to service provider ();

Byte[]x= new byte[]{0x76,0x16,0x12,0x13,0x15, 0x18,…..0x20};16 different values

Code for button1-click[encrypt]

{

Ale stream +s=new file stream(“c://test.text”, file hode.create);

Crypto stream cs=mew crypto stream(fs, f. create encryptor

(x,x),crypto stream hode. white);

String S =”WELCOME”;

Byte[] b = encoding. ASCII. Get bytes(s);

Conrer byte: in stream and store into char

1. Close();

Fs. Close();

Message box. show(“Data in encrypted”);

}

Code for button2 –click

File stream fs = new File stream (“c://test.txt”, File hode open);

crypto stream cs = new crypto stream (fs, t. create

Decryptor (X,X) crypto stream Mode. Read)

Byte[]b= new Byte[100];

Int i=cs. Read (b, o, b. Length);

Name             start

String S= Encoding. ASCII. Get String(b, o, i);

Cs. close();

Cs. close();

Message box. show(s);

}

OBS: same Byte array must be used for encryption and decryption.

WORKING WITH ROLE BASED SECURITY:-

Role based security is the concept of using os level security at.NET Application level Role based security is also called as windows

Authentication or  principle security.

Generally o/s supports 3 types of roles(privilage)

• Users
• Guest

My computersRt clickmanagers or member of Rt click on users àabc

Users xyzrajrani

Under one line Administrator may be placed with any number of names.

To work with ROLEBASED SECURITY,.NET introduced system. Security.  Principle  name space.

Windows identify I,e predefined class, which is used to find the logged in user name

Windows Principle is a predefined class, which is used to find the ROLE of logged in user.

Example on Role based Security:-

Open WFAD with name ROLES (form1)

Add a new form with form name(form2)

And back color =green

Add one more form with name form3 and with back color = red.

Place a button in form

Using  system. Security. Principle;

Code for button1-click

{

Windows Identify w= Windows Identify. Get(current)

Message  box. show(w name);

Windows. Principal = new Windows. Principal(w);

If(p.IS IN ROLW (Windows Built in role. Administrator==true)

{

Form2 f = new form2();

1. shows();

}