This blog is about the dotnet.all types of codes,news about dotnet including asp.net,vb.net,c# and know about new dotnet technology.programing in asp.net,vb.net,c#, ajax, AJAX tech support for .net and discuss the new technology in dotnet.ncluding asp.net,vb.net,c# and know about new dotnet technology.programing in asp.net,vb.net,c#, ajax, AJAX tech support for .net and discuss the new technology in dotnet.asp.net programming,dot net programming,dotnet programs,dotnet source code,source code.

Free Hosting

Free Hosting

Tuesday, November 11, 2008

Dotnet(.Net) Crypto(RC2)



RC2 is a variable key-size block cipher designed by Ronald Rivest for RSA Data Security (now RSA Security). "RC" stands for "Ron's Code" or "Rivest's Cipher.

Read more on CR2



/*
* csharp-home.com or nerdandy@gmail.com for questions and answers
* Enjoy!!
* */
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Windows.Forms;
using System.Security.Cryptography;

namespace Security
{
class GCript
{
byte[] gKey;
byte[] gIV;
byte[] gCypher;
string gData;
RC2CryptoServiceProvider gRC2;

public GCript()
{
gRC2 = new RC2CryptoServiceProvider();
gKey = gRC2.Key;
gIV = gRC2.IV;
}
public string GEnCript(string data)
{
gData=data;

ICryptoTransform gICTP = gRC2.CreateEncryptor(this.gKey, this.gIV);
MemoryStream gMS = new MemoryStream();
CryptoStream gCS = new CryptoStream(gMS, gICTP,CryptoStreamMode.Write);

byte[] gFormat = Encoding.ASCII.GetBytes(gData);
gCS.Write(gFormat, 0, gFormat.Length);
gCS.FlushFinalBlock();
gCypher = gMS.ToArray();

return Encoding.ASCII.GetString(gMS.ToArray());
}

public string GDeCript()
{
ICryptoTransform gDCTP = gRC2.CreateDecryptor(this.gKey, this.gIV);
MemoryStream? gMS = new MemoryStream(gCypher);
CryptoStream? gCS = new CryptoStream(gMS, gDCTP, CryptoStreamMode?.Read);

byte[] gDC = new bytegCypher.Length;
gCS.Read(gDC, 0, gCypher.Length);

return Encoding.ASCII.GetString(gDC);
}

}
}

0 comments:

dotnet(.Net) Project Source code Downloads and Tutorials

Email Subscrption



Enter your email address:

Delivered by FeedBurner

Feedburner Count

Blog Archive

Unique Visitor

Design by araba-cı | MoneyGenerator Blogger Template by GosuBlogger