Xite Encryption


Overview

This class contains methods/functions for easily decrypting and encrypting data.

This is a code file that you can include in your solution in Visual Studio, or a code to add in your current projects, files elsewhere. 

Description

This is code for encrypting and decrypting data, it is made to make it really easy to make applications that should contain encryption, and/or send encrypted data. This class is using: System; System.Security; System.Security.Cryptography;

How to use this class:

How to initialize XiteEncryption?

Xite.Encryption myCrypto = new Xite.Encryption();
Example: How to encrypt a message?
byte[] myEncryptedData = myCrypto.EncryptData( System.Text.ASCIIEncoding.ASCII.GetBytes( "Your Message here!" ) );

Example:

How to decrypt the encrypted message?

string myDecryptedData = System.Text.ASCIIEncoding.ASCII.GetString( myCrypto.DecryptData( myEncryptedData ) );

Source Code

using
System;
using
System.Security;
using
System.Security.Cryptography;
namespace
Xite
{
public class
Encryption
{
// Encryption made easy with RSA
// Both in and out data is in ByteArrays
// @Copyright(C)2002 Kjetil Red
//
// This file/code may freely be used in your solution
// Just add this file to your solution and access it like
// shown in the examples below.
//
// Example: How to initialize XiteEncryption?
// Xite.Encryption myCrypto = new Xite.Encryption();
//
// Example: How to encrypt a message?
// byte[] myEncryptedData = myCrypto.EncryptData( System.Text.ASCIIEncoding.ASCII.GetBytes( "Your Message here!" ) );
//
// Example: How to decrypt the encrypted message?
// (Remeber that the encrypted that is in a byteArray, it's return as a byteArray when encrypted
// string myDecryptedData = System.Text.ASCIIEncoding.ASCII.GetString( myCrypto.DecryptData( myEncryptedData ) );
//
// Happy Crypting :)
// Initializing the RSA Cryptography Service Provider (CSP)
RSACryptoServiceProvider RSAXiteProvider = new
RSACryptoServiceProvider();
// Declaring the Output data as a bytearray
private byte[] XiteOutputMsg = null
;
public byte[] EncryptData( byte
[] XiteData )
{
// Encrypting the data recived
XiteOutputMsg = RSAXiteProvider.Encrypt( XiteData, true
);
//Returning the data decrypted
return
( XiteOutputMsg );
}
public byte[] DecryptData( byte
[] XiteData )
{
// Decrypting the encrypted data recived)
XiteOutputMsg = RSAXiteProvider.Decrypt( XiteData, true
);
// Returning the data decrypted and in it's original way
return
( XiteOutputMsg );
}
}
}

Up Next
    Ebook Download
    View all
    Learn
    View all