It's really depressing to have my password down this year.
Des
Using System;
Using System. IO;
Using System. Security. cryptography;
Namespace Vavic
{
/**/ /// <Summary>
///Security summary.
/// </Summary>
Public Class Security
{
Const String Key_64 = " Vavicapp " ;
Const String Iv_64 = " Vavicapp " ; // It must be 8 characters long and 64-bit.
Public Security ()
{
//
//Todo: add the constructor logic here
//
}
Public Static String Encode ( String Data)
{
Byte [] Bykey = System. Text. asciiencoding. ASCII. getbytes (key_64 );
Byte [] Byiv = System. Text. asciiencoding. ASCII. getbytes (iv_64 );
Descryptoserviceprovider cryptoprovider = New Descryptoserviceprovider ();
Int I = Cryptoprovider. keysize;
Memorystream MS = New Memorystream ();
Cryptostream CST = New Cryptostream (MS, cryptoprovider. createencryptor (bykey, byiv), cryptostreammode. Write );
Streamwriter SW = New Streamwriter (Cst );
Sw. Write (data );
Sw. Flush ();
CST. flushfinalblock ();
Sw. Flush ();
Return Convert. tobase64string (Ms. getbuffer (), 0 ,( Int ) Ms. Length );
}
Public Static String Decode ( String Data)
{
Byte [] Bykey = System. Text. asciiencoding. ASCII. getbytes (key_64 );
Byte [] Byiv = System. Text. asciiencoding. ASCII. getbytes (iv_64 );
Byte [] Byenc;
Try
{
Byenc=Convert. frombase64string (data );
}
Catch
{
Return Null;
}
Descryptoserviceprovider cryptoprovider = New Descryptoserviceprovider ();
Memorystream MS = New Memorystream (byenc );
Cryptostream CST = New Cryptostream (MS, cryptoprovider. createdecryptor (bykey, byiv), cryptostreammode. Read );
Streamreader SR = New Streamreader (Cst );
Return Sr. readtoend ();
}
}
}