Click here to Skip to main content
15,891,253 members
Articles / Programming Languages / Visual Basic

Using VB to Create & Check License Keys

Rate me:
Please Sign up or sign in to vote.
4.73/5 (43 votes)
23 May 2007LGPL33 min read 252K   21.6K   148  
Generate and check license keys embedding 16-bit configuration information
<?xml version="1.0"?>
<doc>
<assembly>
<name>
LicenseKeyDemo
</name>
</assembly>
<members>
<member name="F:LicenseKeyDemo.Encryption.Hash.Provider.CRC32">
	<summary>
 Cyclic Redundancy Check provider, 32-bit
 </summary>
</member><member name="F:LicenseKeyDemo.Encryption.Hash.Provider.SHA1">
	<summary>
 Secure Hashing Algorithm provider, SHA-1 variant, 160-bit
 </summary>
</member><member name="F:LicenseKeyDemo.Encryption.Hash.Provider.SHA256">
	<summary>
 Secure Hashing Algorithm provider, SHA-2 variant, 256-bit
 </summary>
</member><member name="F:LicenseKeyDemo.Encryption.Hash.Provider.SHA384">
	<summary>
 Secure Hashing Algorithm provider, SHA-2 variant, 384-bit
 </summary>
</member><member name="F:LicenseKeyDemo.Encryption.Hash.Provider.SHA512">
	<summary>
 Secure Hashing Algorithm provider, SHA-2 variant, 512-bit
 </summary>
</member><member name="F:LicenseKeyDemo.Encryption.Hash.Provider.MD5">
	<summary>
 Message Digest algorithm 5, 128-bit
 </summary>
</member><member name="T:LicenseKeyDemo.Encryption.Hash.Provider">
	<summary>
 Type of hash; some are security oriented, others are fast and simple
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Hash.#ctor(LicenseKeyDemo.Encryption.Hash.Provider)">
	<summary>
 Instantiate a new hash of the specified type
 </summary>
</member><member name="P:LicenseKeyDemo.Encryption.Hash.Value">
	<summary>
 Returns the previously calculated hash
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Hash.Calculate(System.IO.Stream@)">
	<summary>
 Calculates hash on a stream of arbitrary length
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Hash.Calculate(LicenseKeyDemo.Encryption.Data)">
	<summary>
 Calculates hash for fixed length <see cref="T:LicenseKeyDemo.Encryption.Data"/>
	</summary>
</member><member name="M:LicenseKeyDemo.Encryption.Hash.Calculate(LicenseKeyDemo.Encryption.Data,LicenseKeyDemo.Encryption.Data)">
	<summary>
 Calculates hash for a string with a prefixed salt value. 
 A "salt" is random data prefixed to every hashed value to prevent 
 common dictionary attacks.
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Hash.CalculatePrivate(System.Byte[])">
	<summary>
 Calculates hash for an array of bytes
 </summary>
</member><member name="T:LicenseKeyDemo.Encryption.Hash">
	<summary>
 Hash functions are fundamental to modern cryptography. These functions map binary 
 strings of an arbitrary length to small binary strings of a fixed length, known as 
 hash values. A cryptographic hash function has the property that it is computationally
 infeasible to find two distinct inputs that hash to the same value. Hash functions 
 are commonly used with digital signatures and for data integrity.
 </summary>
</member><member name="F:LicenseKeyDemo.Encryption.Symmetric.Provider.DES">
	<summary>
 The Data Encryption Standard provider supports a 64 bit key only
 </summary>
</member><member name="F:LicenseKeyDemo.Encryption.Symmetric.Provider.RC2">
	<summary>
 The Rivest Cipher 2 provider supports keys ranging from 40 to 128 bits, default is 128 bits
 </summary>
</member><member name="F:LicenseKeyDemo.Encryption.Symmetric.Provider.Rijndael">
	<summary>
 The Rijndael (also known as AES) provider supports keys of 128, 192, or 256 bits with a default of 256 bits
 </summary>
</member><member name="F:LicenseKeyDemo.Encryption.Symmetric.Provider.TripleDES">
	<summary>
 The TripleDES provider (also known as 3DES) supports keys of 128 or 192 bits with a default of 192 bits
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Symmetric.#ctor(LicenseKeyDemo.Encryption.Symmetric.Provider,System.Boolean)">
	<summary>
 Instantiates a new symmetric encryption object using the specified provider.
 </summary>
</member><member name="P:LicenseKeyDemo.Encryption.Symmetric.KeySizeBytes">
	<summary>
 Key size in bytes. We use the default key size for any given provider; if you 
 want to force a specific key size, set this property
 </summary>
</member><member name="P:LicenseKeyDemo.Encryption.Symmetric.KeySizeBits">
	<summary>
 Key size in bits. We use the default key size for any given provider; if you 
 want to force a specific key size, set this property
 </summary>
</member><member name="P:LicenseKeyDemo.Encryption.Symmetric.Key">
	<summary>
 The key used to encrypt/decrypt data
 </summary>
</member><member name="P:LicenseKeyDemo.Encryption.Symmetric.IntializationVector">
	<summary>
 Using the default Cipher Block Chaining (CBC) mode, all data blocks are processed using
 the value derived from the previous block; the first data block has no previous data block
 to use, so it needs an InitializationVector to feed the first block
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Symmetric.RandomInitializationVector">
	<summary>
 generates a random Initialization Vector, if one was not provided
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Symmetric.RandomKey">
	<summary>
 generates a random Key, if one was not provided
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Symmetric.ValidateKeyAndIv(System.Boolean)">
	<summary>
 Ensures that _crypto object has valid Key and IV
 prior to any attempt to encrypt/decrypt anything
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Symmetric.Encrypt(LicenseKeyDemo.Encryption.Data,LicenseKeyDemo.Encryption.Data)">
	<summary>
 Encrypts the specified Data using provided key
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Symmetric.Encrypt(LicenseKeyDemo.Encryption.Data)">
	<summary>
 Encrypts the specified Data using preset key and preset initialization vector
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Symmetric.Encrypt(System.IO.Stream,LicenseKeyDemo.Encryption.Data,LicenseKeyDemo.Encryption.Data)">
	<summary>
 Encrypts the stream to memory using provided key and provided initialization vector
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Symmetric.Encrypt(System.IO.Stream,LicenseKeyDemo.Encryption.Data)">
	<summary>
 Encrypts the stream to memory using specified key
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Symmetric.Encrypt(System.IO.Stream)">
	<summary>
 Encrypts the specified stream to memory using preset key and preset initialization vector
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Symmetric.Decrypt(LicenseKeyDemo.Encryption.Data,LicenseKeyDemo.Encryption.Data)">
	<summary>
 Decrypts the specified data using provided key and preset initialization vector
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Symmetric.Decrypt(System.IO.Stream,LicenseKeyDemo.Encryption.Data)">
	<summary>
 Decrypts the specified stream using provided key and preset initialization vector
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Symmetric.Decrypt(System.IO.Stream)">
	<summary>
 Decrypts the specified stream using preset key and preset initialization vector
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Symmetric.Decrypt(LicenseKeyDemo.Encryption.Data)">
	<summary>
 Decrypts the specified data using preset key and preset initialization vector
 </summary>
</member><member name="T:LicenseKeyDemo.Encryption.Symmetric">
	<summary>
 Symmetric encryption uses a single key to encrypt and decrypt. 
 Both parties (encryptor and decryptor) must share the same secret key.
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Asymmetric.PublicKey.LoadFromConfig">
	<summary>
 Load public key from App.config or Web.config file
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Asymmetric.PublicKey.ToConfigSection">
	<summary>
 Returns *.config file XML section representing this public key
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Asymmetric.PublicKey.ExportToConfigFile(System.String)">
	<summary>
 Writes the *.config file representation of this public key to a file
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Asymmetric.PublicKey.LoadFromXml(System.String)">
	<summary>
 Loads the public key from its XML string
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Asymmetric.PublicKey.ToParameters">
	<summary>
 Converts this public key to an RSAParameters object
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Asymmetric.PublicKey.ToXml">
	<summary>
 Converts this public key to its XML string representation
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Asymmetric.PublicKey.ExportToXmlFile(System.String)">
	<summary>
 Writes the Xml representation of this public key to a file
 </summary>
</member><member name="T:LicenseKeyDemo.Encryption.Asymmetric.PublicKey">
	<summary>
 Represents a public encryption key. Intended to be shared, it 
 contains only the Modulus and Exponent.
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Asymmetric.PrivateKey.LoadFromConfig">
	<summary>
 Load private key from App.config or Web.config file
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Asymmetric.PrivateKey.ToParameters">
	<summary>
 Converts this private key to an RSAParameters object
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Asymmetric.PrivateKey.ToConfigSection">
	<summary>
 Returns *.config file XML section representing this private key
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Asymmetric.PrivateKey.ExportToConfigFile(System.String)">
	<summary>
 Writes the *.config file representation of this private key to a file
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Asymmetric.PrivateKey.LoadFromXml(System.String)">
	<summary>
 Loads the private key from its XML string
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Asymmetric.PrivateKey.ToXml">
	<summary>
 Converts this private key to its XML string representation
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Asymmetric.PrivateKey.ExportToXmlFile(System.String)">
	<summary>
 Writes the Xml representation of this private key to a file
 </summary>
</member><member name="T:LicenseKeyDemo.Encryption.Asymmetric.PrivateKey">
	<summary>
 Represents a private encryption key. Not intended to be shared, as it 
 contains all the elements that make up the key.
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Asymmetric.#ctor">
	<summary>
 Instantiates a new asymmetric encryption session using the default key size; 
 this is usally 1024 bits
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Asymmetric.#ctor(System.Int32)">
	<summary>
 Instantiates a new asymmetric encryption session using a specific key size
 </summary>
</member><member name="P:LicenseKeyDemo.Encryption.Asymmetric.KeyContainerName">
	<summary>
 Sets the name of the key container used to store this key on disk; this is an 
 unavoidable side effect of the underlying Microsoft CryptoAPI. 
 </summary>
	<remarks>
 http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q322/3/71.asp&amp;NoWebContent=1
 </remarks>
</member><member name="P:LicenseKeyDemo.Encryption.Asymmetric.KeySizeBits">
	<summary>
 Returns the current key size, in bits
 </summary>
</member><member name="P:LicenseKeyDemo.Encryption.Asymmetric.KeySizeMaxBits">
	<summary>
 Returns the maximum supported key size, in bits
 </summary>
</member><member name="P:LicenseKeyDemo.Encryption.Asymmetric.KeySizeMinBits">
	<summary>
 Returns the minimum supported key size, in bits
 </summary>
</member><member name="P:LicenseKeyDemo.Encryption.Asymmetric.KeySizeStepBits">
	<summary>
 Returns valid key step sizes, in bits
 </summary>
</member><member name="P:LicenseKeyDemo.Encryption.Asymmetric.DefaultPublicKey">
	<summary>
 Returns the default public key as stored in the *.config file
 </summary>
</member><member name="P:LicenseKeyDemo.Encryption.Asymmetric.DefaultPrivateKey">
	<summary>
 Returns the default private key as stored in the *.config file
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Asymmetric.GenerateNewKeyset(LicenseKeyDemo.Encryption.Asymmetric.PublicKey@,LicenseKeyDemo.Encryption.Asymmetric.PrivateKey@)">
	<summary>
 Generates a new public/private key pair as objects
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Asymmetric.GenerateNewKeyset(System.String@,System.String@)">
	<summary>
 Generates a new public/private key pair as XML strings
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Asymmetric.Encrypt(LicenseKeyDemo.Encryption.Data)">
	<summary>
 Encrypts data using the default public key
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Asymmetric.Encrypt(LicenseKeyDemo.Encryption.Data,LicenseKeyDemo.Encryption.Asymmetric.PublicKey)">
	<summary>
 Encrypts data using the provided public key
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Asymmetric.Encrypt(LicenseKeyDemo.Encryption.Data,System.String)">
	<summary>
 Encrypts data using the provided public key as XML
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Asymmetric.Decrypt(LicenseKeyDemo.Encryption.Data)">
	<summary>
 Decrypts data using the default private key
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Asymmetric.Decrypt(LicenseKeyDemo.Encryption.Data,LicenseKeyDemo.Encryption.Asymmetric.PrivateKey)">
	<summary>
 Decrypts data using the provided private key
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Asymmetric.Decrypt(LicenseKeyDemo.Encryption.Data,System.String)">
	<summary>
 Decrypts data using the provided private key as XML
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Asymmetric.GetRSAProvider">
	<summary>
 gets the default RSA provider using the specified key size; 
 note that Microsoft's CryptoAPI has an underlying file system dependency that is unavoidable
 </summary>
	<remarks>
 http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q322/3/71.asp&amp;NoWebContent=1
 </remarks>
</member><member name="T:LicenseKeyDemo.Encryption.Asymmetric">
	<summary>
 Asymmetric encryption uses a pair of keys to encrypt and decrypt.
 There is a "public" key which is used to encrypt. Decrypting, on the other hand, 
 requires both the "public" key and an additional "private" key. The advantage is 
 that people can send you encrypted messages without being able to decrypt them.
 </summary>
	<remarks>
 The only provider supported is the <see cref="T:System.Security.Cryptography.RSACryptoServiceProvider"/>
	</remarks>
</member><member name="F:LicenseKeyDemo.Encryption.Data.DefaultEncoding">
	<summary>
 Determines the default text encoding across ALL Data instances
 </summary>
</member><member name="F:LicenseKeyDemo.Encryption.Data.Encoding">
	<summary>
 Determines the default text encoding for this Data instance
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Data.#ctor">
	<summary>
 Creates new, empty encryption data
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Data.#ctor(System.Byte[])">
	<summary>
 Creates new encryption data with the specified byte array
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Data.#ctor(System.String)">
	<summary>
 Creates new encryption data with the specified string; 
 will be converted to byte array using default encoding
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Data.#ctor(System.String,System.Text.Encoding)">
	<summary>
 Creates new encryption data using the specified string and the 
 specified encoding to convert the string to a byte array.
 </summary>
</member><member name="P:LicenseKeyDemo.Encryption.Data.IsEmpty">
	<summary>
 returns true if no data is present
 </summary>
</member><member name="P:LicenseKeyDemo.Encryption.Data.StepBytes">
	<summary>
 allowed step interval, in bytes, for this data; if 0, no limit
 </summary>
</member><member name="P:LicenseKeyDemo.Encryption.Data.StepBits">
	<summary>
 allowed step interval, in bits, for this data; if 0, no limit
 </summary>
</member><member name="P:LicenseKeyDemo.Encryption.Data.MinBytes">
	<summary>
 minimum number of bytes allowed for this data; if 0, no limit
 </summary>
</member><member name="P:LicenseKeyDemo.Encryption.Data.MinBits">
	<summary>
 minimum number of bits allowed for this data; if 0, no limit
 </summary>
</member><member name="P:LicenseKeyDemo.Encryption.Data.MaxBytes">
	<summary>
 maximum number of bytes allowed for this data; if 0, no limit
 </summary>
</member><member name="P:LicenseKeyDemo.Encryption.Data.MaxBits">
	<summary>
 maximum number of bits allowed for this data; if 0, no limit
 </summary>
</member><member name="P:LicenseKeyDemo.Encryption.Data.Bytes">
	<summary>
 Returns the byte representation of the data; 
 This will be padded to MinBytes and trimmed to MaxBytes as necessary!
 </summary>
</member><member name="P:LicenseKeyDemo.Encryption.Data.Text">
	<summary>
 Sets or returns text representation of bytes using the default text encoding
 </summary>
</member><member name="P:LicenseKeyDemo.Encryption.Data.Hex">
	<summary>
 Sets or returns Hex string representation of this data
 </summary>
</member><member name="P:LicenseKeyDemo.Encryption.Data.Base64">
	<summary>
 Sets or returns Base64 string representation of this data
 </summary>
</member><member name="P:LicenseKeyDemo.Encryption.Data.Base32">
	<summary>
 Sets or returns Base32 string representation of this data
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Data.ToString">
	<summary>
 Returns text representation of bytes using the default text encoding
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Data.ToBase64">
	<summary>
 returns Base64 string representation of this data
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Data.ToBase32">
	<summary>
 returns Base32 string representation of this data
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Data.ToHex">
	<summary>
 returns Hex string representation of this data
 </summary>
</member><member name="T:LicenseKeyDemo.Encryption.Data">
	<summary>
 represents Hex, Byte, Base64, or String data to encrypt/decrypt;
 use the .Text property to set/get a string representation 
 use the .Hex property to set/get a string-based Hexadecimal representation 
 use the .Base64 to set/get a string-based Base64 representation 
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Utils.ToHex(System.Byte[])">
	<summary>
 converts an array of bytes to a string Hex representation
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Utils.FromHex(System.String)">
	<summary>
 converts from a string Hex representation to an array of bytes
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Utils.FromBase64(System.String)">
	<summary>
 converts from a string Base64 representation to an array of bytes
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Utils.ToBase64(System.Byte[])">
	<summary>
 converts from an array of bytes to a string Base64 representation
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Utils.GetXmlElement(System.String,System.String)">
	<summary>
 retrieve an element from an XML string
 </summary>
</member><member name="M:LicenseKeyDemo.Encryption.Utils.GetConfigString(System.String,System.Boolean)">
	<summary>
 Returns the specified string value from the application .config file
 </summary>
</member><member name="T:LicenseKeyDemo.Encryption.Utils">
	<summary>
 Friend class for shared utility methods used by multiple Encryption classes
 </summary>
</member>
</members>
</doc>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)


Written By
Systems Engineer iServe Technologies
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions