vb.net generate barcode 128 Symmetrical Encryption in Visual Basic .NET

Maker Code-128 in Visual Basic .NET Symmetrical Encryption

Symmetrical Encryption
Print USS Code 128 In Visual Basic .NET
Using Barcode printer for .NET framework Control to generate, create Code 128 Code Set C image in .NET applications.
www.OnBarcode.com
Read Code 128 Code Set A In VB.NET
Using Barcode reader for .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
The .NET Framework supports the following symmetrical encryption algorithms:
Bar Code Creation In Visual Basic .NET
Using Barcode creator for Visual Studio .NET Control to generate, create barcode image in .NET framework applications.
www.OnBarcode.com
Bar Code Recognizer In Visual Basic .NET
Using Barcode scanner for .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
DES TripleDES RC2 Rijndael (also known as AES)
Creating Code 128A In Visual C#.NET
Using Barcode printer for .NET framework Control to generate, create Code 128C image in VS .NET applications.
www.OnBarcode.com
Code 128 Code Set C Creation In .NET Framework
Using Barcode generator for ASP.NET Control to generate, create Code 128 Code Set B image in ASP.NET applications.
www.OnBarcode.com
17. Security and Cryptography
Generate Code 128 Code Set C In VS .NET
Using Barcode generation for .NET Control to generate, create Code 128A image in .NET framework applications.
www.OnBarcode.com
Draw QR Code ISO/IEC18004 In Visual Basic .NET
Using Barcode creator for .NET framework Control to generate, create QR Code 2d barcode image in VS .NET applications.
www.OnBarcode.com
The base class for all symmetrical algorithms is System.Security.Cryptography.SymmetricAlgorithm. This class provides the basic members for encrypting data as well as creating keys and initialization vectors (IVs), which are nonsecret binary inputs to the algorithms. Each of the supported algorithms is represented by an abstract class and a default implementation class; the abstract class allows alternative implementations of algorithms to be used, such as those that accelerate encryption by using hardware. Table 17-5 lists the abstract and default implementation classes for each algorithm; all classes are members of the System.Security.Cryptography namespace.
Data Matrix ECC200 Generation In Visual Basic .NET
Using Barcode printer for VS .NET Control to generate, create Data Matrix ECC200 image in Visual Studio .NET applications.
www.OnBarcode.com
Barcode Encoder In Visual Basic .NET
Using Barcode drawer for VS .NET Control to generate, create barcode image in Visual Studio .NET applications.
www.OnBarcode.com
Table 17-5. Symmetric Encryption Classes
1D Generation In VB.NET
Using Barcode maker for Visual Studio .NET Control to generate, create Linear 1D Barcode image in .NET framework applications.
www.OnBarcode.com
ISSN Maker In Visual Basic .NET
Using Barcode printer for Visual Studio .NET Control to generate, create ISSN - 10 image in Visual Studio .NET applications.
www.OnBarcode.com
Abstract Class DES RC2 Rijndael TripleDES
Create Code 128A In Java
Using Barcode generator for Android Control to generate, create USS Code 128 image in Android applications.
www.OnBarcode.com
Paint Barcode In None
Using Barcode creation for Word Control to generate, create barcode image in Microsoft Word applications.
www.OnBarcode.com
Implementation Class DESCryptoServiceProvider RC2CryptoServiceProvider RijndaelManaged TripleDESCryptoServiceProvider
QR Code JIS X 0510 Printer In None
Using Barcode generation for Office Excel Control to generate, create QR-Code image in Excel applications.
www.OnBarcode.com
Create Data Matrix 2d Barcode In None
Using Barcode printer for Word Control to generate, create Data Matrix 2d barcode image in Microsoft Word applications.
www.OnBarcode.com
The key and IV can be generated using the GenerateKey and GenerateIV methods or set using the Key and IV properties. Reading and writing encrypted data are supported through the streams model using the System.Security.Cryptography.CryptoStream class. See 10, "Streams, Files, and I/O," for general information on streams. The CryptoStream constructor takes three arguments, as detailed in Table 17-6.
Drawing ECC200 In .NET
Using Barcode drawer for Reporting Service Control to generate, create ECC200 image in Reporting Service applications.
www.OnBarcode.com
EAN / UCC - 13 Generation In VS .NET
Using Barcode encoder for ASP.NET Control to generate, create UPC - 13 image in ASP.NET applications.
www.OnBarcode.com
Table 17-6. CryptoStream Constructor Arguments
Barcode Creator In Java
Using Barcode generation for Java Control to generate, create barcode image in Java applications.
www.OnBarcode.com
PDF 417 Printer In None
Using Barcode drawer for Word Control to generate, create PDF417 image in Word applications.
www.OnBarcode.com
Description The Stream that should be used for reading or writing. System.Security.Cryptography.ICryptoTransform A class that can perform cryptographic transformations (encrypting and decrypting data). Transformers can be obtained using the CreateDecryptor and CreateEncryptor methods from the SymmetricAlgorithm class. System.Security.Cryptography.CryptoStreamMode An enumeration value that specifies whether the CryptoStream instance will be used to read or write data. The following example demonstrates how to write encrypted data to a MemoryStream and then read it back, using the Triple DES algorithm:
using using using using System; System.Security.Cryptography; System.IO; System.Text;
Constructor Argument Type System.IO.Stream
class DESExample { DESExample() { byte[] x_secret_message = Encoding.Default.GetBytes("C# for Java Developers");
17. Security and Cryptography // create the provider and generate the key and IV TripleDESCryptoServiceProvider x_3des = new TripleDESCryptoServiceProvider(); x_3des.GenerateKey(); x_3des.GenerateIV(); // create the memory stream to hold the encrypted data MemoryStream x_memory_stream = new MemoryStream(); // create the cryto stream CryptoStream x_crypto_stream = new CryptoStream( x_memory_stream, x_3des.CreateEncryptor(x_3des.Key, x_3des.IV), CryptoStreamMode.Write); // write the data to the crypto stream x_crypto_stream.Write(x_secret_message, 0, x_secret_message.Length); x_crypto_stream.Flush(); // create a crypto stream to read the data x_crypto_stream = new CryptoStream( x_memory_stream, x_3des.CreateDecryptor(x_3des.Key, x_3des.IV), CryptoStreamMode.Read); // read and print the secret message x_crypto_stream.Read(x_secret_message, 0, x_secret_message.Length); Console.WriteLine(Encoding.Default.GetString(x_secret_message)); } static void Main(string[] args) { new DESExample(); } }
Asymmetrical Encryption
The .NET Framework provides support for the asymmetrical encryption algorithms DSA and RSA. The class hierarchy for asymmetrical encryption follows the same model as for symmetrical algorithms. The abstract class System.Security.Cryptography.AsymmetricAlgorithm provides the basic members, which are accompanied by abstract and concrete implementations for each of the algorithms, as detailed in Table 17-7.
Table 17-7. Asymmetric Encryption Classes
Abstract Class Implementation Class System.Security.Cryptography.DSA System.Security.Cryptography.DSACryptoServiceProvider System.Security.Cryptography.RSA System.Security.Cryptography.RSACryptoServiceProvider A public/private key pair is generated automatically when the implementation classes are instantiated; the key information can be extracted in the following ways:
By using the ExportParameters method, which returns a class representing the key information (either DSAParameters or RSAParameters) By using the ToXmlString method, which returns an XML description of the key pair
17. Security and Cryptography
Both methods of obtaining the key information take a bool argument to specify whether the private key element should be included in the output. ImportParameters and FromXmlString allow previously generated keys to be imported. Unlike the symmetrical algorithms, the RSA and DSA classes do not support encrypting and decrypting data through streams; the asymmetrical algorithm classes work on byte arrays. The following example demonstrates how to use the RSA algorithm to encrypt data and then decrypt it:
using System; using System.Security.Cryptography; using System.Text; class RSAExample { RSAExample() { byte[] x_secret_message = Encoding.Default.GetBytes("C# for Java Developers"); // create the RSA provider RSACryptoServiceProvider x_rsa_encryptor = new RSACryptoServiceProvider(); // extract the parameters so we can decrypt the data later RSAParameters x_key_info = x_rsa_encryptor.ExportParameters(true); // encrypt the data byte[] x_encrypted_data = x_rsa_encryptor.Encrypt(x_secret_message, false); // create the RSA provider RSACryptoServiceProvider x_rsa_decryptor = new RSACryptoServiceProvider(); x_rsa_decryptor.ImportParameters(x_key_info); // decrypt the data x_secret_message = x_rsa_decryptor.Decrypt(x_encrypted_data, false); Console.WriteLine(Encoding.Default.GetString(x_secret_message));
static void Main(string[] args) { new RSAExample(); }
Copyright © OnBarcode.com . All rights reserved.