Working with crypto Graphy

Working with crypto Graphy:-

 

Screenshot_51

 

 

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

Screenshot_24Open WFAP

Screenshot_24Place 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.

Screenshot_24Code in GD[Before button1]

 

Screenshot_52

 

Screenshot_24Code 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

Screenshot_24Code 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

 

Screenshot_53

  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:-

Screenshot_54

 

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

Screenshot_24Authentication or  principle security.

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

  • Administrator
  • Users
  • Guest

My computersScreenshot_24Rt clickScreenshot_24managers or member of Rt click on users àabc

Users Screenshot_24xyzScreenshot_24rajScreenshot_24rani

 

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

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

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

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

 

Example on Role based Security:-

Screenshot_24Open 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.

Screenshot_24Place 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)

{

Message  box. show(“Admini”);

Form2 f = new form2();

  1. shows();

}

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on Working with crypto Graphy"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Support


    Please leave a message and we'll get back to you soon.
    Three + 6