LLCryptoLib.Crypto library contains the functions to encrypt and decrypt any stream or text file.

Classes

  ClassDescription
Public classAsymmetricCrypter
Asymmetric Crypter class. This class implements RSA public key encryption. Public key means that a message encrypted with a recipient's public key cannot be decrypted by anyone except the recipient possessing the corresponding private key. To make such encryption, AsymmetricCrypter implements RSA algorithm. Since this algorithm is relatively computationally costly in comparison with many symmetric key algorithms of equivalent security, AsymmetricCrypter implements an hybrid asymmetric/symmetric cryptosystem for reasons of efficiency; in such a cryptosystem, a shared secret key ("session key") is generated by one party and this much briefer session key is then encrypted by each recipient's public key. Each recipient uses the corresponding private key to decrypt the session key. The message is then encrypted with a symmetric algorithm ciphered with the session key. This is why the constructor of AsymmetricCrypter takes in input a SupportedStreamAlgorithms object, to determine the symmetric algorithm that will be used to encrypt the message. Instead, the random generated key is ciphered with RSA algorithm. This class also offers some utility methods to acquire public and private keys from certificates or external files in several formats, such as: CER, PEM or XML.
Public classBlowfishCBC
Blowfish CBC implementation.
Public classBlowfishECB
Blowfish ECB implementation.
Public classBlowfishManaged
Blowfish is a keyed, symmetric block cipher, designed in 1993 by Bruce Schneier and included in a large number of cipher suites and encryption products. Blowfish provides a good encryption rate in software and no effective cryptanalysis of it has been found to date. Schneier designed Blowfish as a general-purpose algorithm, intended as a replacement for the aging DES and free of the problems and constraints associated with other algorithms. This implementation of the Blowfish algorithm as a standard component for the .NET security framework.
Public classCast5Managed
Implementation of the CAST-128 algorithm as a standard component for the .NET security framework. In cryptography, CAST5 (alternatively CAST-128) is a block cipher used in a number of products, notably as the default cipher in some versions of GPG and PGP. It has also been approved for Canadian government use by the Communications Security Establishment. The algorithm was created in 1996 by Carlisle Adams and Stafford Tavares using the CAST design procedure; another member of the CAST family of ciphers, CAST-256 (a former AES candidate) was derived from CAST-128. According to some sources, the "CAST" name is based on the initials of its inventors, though Bruce Schneier reports the authors' claim that "the name should conjure up images of randomness" (Schneier, 1996). CAST-128 is a 12- or 16-round Feistel network with a 64-bit block size and a key size of between 40 to 128 bits (but only in 8-bit increments). The full 16 rounds are used when the key size is longer than 80 bits. Components include large 8×32-bit S-boxes based on bent functions, key-dependent rotations, modular addition and subtraction, and XOR operations. There are three alternating types of round function, but they are similar in structure and differ only in the choice of the exact operation (addition, subtraction or XOR) at various points. Although Entrust holds a patent on the CAST design procedure, CAST-128 is available worldwide on a royalty-free basis for commercial and non-commercial uses.
Public classStream3DES
3DES 128bit A variant of DES, Triple-DES or 3DES is based on using DES three times (an encrypt-decrypt-encrypt sequence with three different, unrelated keys). Many people consider Triple-DES to be much safer than plain DES.
Public classStreamAES
AES 128bit. The American Encyption Standard recogninized by NIST (National Institute of Standards and Technology) The AES, aka Rijndael, is a cipher by two Belgian cryptographers, Joan Daemen and Vincent Rijmen. Rijndael follows the tradition of square ciphers (it is based on ideas similar to the Square cipher). NIST gave as its reasons for selecting Rijndael that it performs very well in hardware and software across a wide range of environments in all possible modes. It has excellent key setup time and has low memory requirements, in addition its operations are easy to defend against power and timing attacks.
Public classStreamAES192
AES 192bit.
Public classStreamAES256
AES 256bit
Public classStreamAlgorithm
Encryption Algorithm. A StreamAlgorithm class indicates the algorithm to be used in Stream Encryption. StreamCrypter
Public classStreamAlgorithmFactory
A StreamAlgorithmFactory is a factory class to create IStreamAlgorithm objects based on their description or IDs.
Public classStreamARC4
ARC4 128bit. ARC4 is short for `Alleged RC4'. The real RC4 algorithm is proprietary to RSA Data Security Inc. In September 1994, someone posted C code to both the Cypherpunks mailing list and to the Usenet newsgroup @code{sci.crypt}, claiming that it implemented the RC4 algorithm. This posted code is what it being called Alleged RC4, or ARC4 for short. ARC4 is a private-key cipher; the same key is used to both encrypt and decrypt.
Public classStreamARC41024
ARC4 1024bit
Public classStreamARC42048
ARC4 2048bit
Public classStreamARC4512
ARC4 algorithm at 512bit
Public classStreamARC4Base
Base class for all ARC4 classes
Public classStreamBlowfish
StreamBlowfish implements Blowfish for streams. Key len = 16 byte Block len = 8 byte
Public classStreamBlowfish256
StreamBlowfish 256 bit Key len = 32 byte Block len = 8 byte

Examples

Perform a Blowfish stream encryption.
CopyC#
Set encryption algorithm
IStreamAlgorithm encryptAlgo = new StreamBlowfish256();
StreamCrypter encrypter = new StreamCrypter(encryptAlgo);
// Set symmetric password
encrypter.GenerateKeys("littlelitesoftware");
// Encrypt
encrypter.EncryptDecrypt(rndFile.FullName, encryptedFile, true, null);
Console.WriteLine("File encrypted into " + encryptedFile);
Public classStreamBlowfish448
StreamBlowfish 448 bit Key len = 56 byte Block len = 8 byte

Examples

Perform a Blowfish stream encryption.
CopyC#
// Set encryption algorithm
IStreamAlgorithm encryptAlgo = new StreamBlowfish448();
StreamCrypter encrypter = new StreamCrypter(encryptAlgo);
// Set symmetric password
encrypter.GenerateKeys("littlelitesoftware");
// Encrypt
encrypter.EncryptDecrypt(rndFile.FullName, encryptedFile, true, null);
Console.WriteLine("File encrypted into " + encryptedFile);
Public classStreamCast
StreamCast implements CAST5 (aka CAST-128) for streams. Key len = 8 byte Block len = 8 byte
Public classStreamCrypter
This class wraps the operations on encryption streams.
Public classStreamDES
DES 64bit. DES is an algorithm developed in the 1970s. It was made a standard by the US government, and has also been adopted by several other governments worldwide. It is widely used, especially in the financial industry. DES is a block cipher with 64-bit block size. It uses 56-bit keys. This makes it fairly easy to break with modern computers or special-purpose hardware. DES is still strong enough to keep most random hackers and individuals out, but it is easily breakable with special hardware by government, criminal organizations, or major corporations. In large volumes, the cost of beaking DES keys is on the order of tens of dollars. DES is getting too weak, and should not be used in new designs.
Public classStreamThreeFish
StreamThreeFish implements Threefish for streams. Key len = 32 byte Block len = 32 byte
Public classStreamThreeFish1024
StreamThreeFish implements Threefish for streams. Key len = 128 byte Block len = 128 byte
Public classStreamThreeFish512
StreamThreeFish implements Threefish for streams. Key len = 64 byte Block len = 64 byte
Public classTextAlgorithm
TextAlgorithm The 'TextAlgorithm' perform these conversions in the crypting phase: - Text in clear is converted into array of bytes with 'StringToBytes' - Bytes are passed to encryption algorithm - Encryption algorithm returns a MemoryStream - MemoryStream is turned into a Base64 string with 'MemoryToBase64String' And these when decrypting: - Text must be in Base64 in order to be decrypted - Base64 string is turned into bytes with 'Base64StringToBytes' - Bytes are passed to decryption algorithm - Decryption returns a MemoryStream - MemoryStream is turned into clear text with 'MemoryToString' To create a TextAlgorithm see, for instance, TextROT13 TextROT13
Public classTextAlgorithmParameters
Class to share parameters between different crypto methods.
Public classTextCrypter
A TextCrypter object is used to encrypt or decrypt strings.
Public classTextCrypterFactory
A TextCryptFactory is a factory class for TextCrypter object. The user must supply an algorithm ID and some parameters and he gets an initialized TextCrypter object
Public classTextEncryptionUtils
Utility for text encryption
Public classTextPlayfair
TextPlayfair cipher. The TextPlayfair is a primitively modern reckoning block cipher. Any new personal computer sold today can break a message encoded with it in a matter of seconds. That is, with the proper software, you could use such a computer to discover the original text without knowing the cipher key. Some skilled cryptogrophists and puzzle experts can even break it with nothing more than pen and paper. Nonetheless, it uses some principles common to modern computer block ciphers. Understanding the TextPlayfair will give you a beginning insight into modern cryptographywithout all the complex mathematics and number theory. TextPlayfair Cipher uses a 5x5 or 9x9 square, in which the letters of an agreed key word or phrase are entered (suppressing duplicates), followed by the rest of the alphabet in order (if 5x5 is used then an alphabet with 25 letters is used where I and J would usually be combined together, if 9x9 is used a broader range of symbols is used. The more the symbols, the more the characters that can be encrypted). The message to be enciphered is split into pairs of letters. If the two letters in the pair are in the same row, the letters to the right of each are used. If they are in the same column, the letters below each are used. Otherwise, the letters at the opposite corners of the rectangle are used. Special treatment is required for identical pairs of letters and a single letter left over at the end. Typically an obscure letter such as X would have been inserted to pad out the message. LLCryptoLib implementations assumes, instead of the original 5x5 or 9x9 cipher, a combined 36x36 square.
Public classTextPseudoDes
PseudoDES text encoding class. PseudoDES is a TextVigenere type of encoding, remade for a number of times equal to TextAlgorithmParameters.Shift. If TextAlgorithmParameters.Shift is zero, then a value of 7 is taken.
Public classTextROT13
Performs a TextROT13 transformation. In 50 Bc., one of the most simple cryptographic algorithms ever used was the one called the TextROT13 cipher, that was used by Julius TextROT13 to send messages to his generals. It consisted simply of switching each letter with the letter that was 3 letters further down the alphabet. For example Stephen would become Vwhskhq. To decrypt the message, the receivers would simply subtract 3 letters from each letter. This algorithm was later improved and called TextROT13, where the letters could be shifted to any number between 1 and 25, and the number of letters shifted was the secret key. In this implementation, the shift may be any short number > 1.
Public classTextVigenere
Implements Vigenere/Polyalphabetical Text Crypto Algorithm. The Vigenere encryption was the creation of the French diplomat, Blaise de Vigenere, 1523-1596. Like Caesar and all the cryptographers that followed, he did not visualize the cipher in modular arithmetical terms. Rather he viewed the cypher as a substitution cipher where a different alphabet was used for the next letter of the message, with the alphabets repeating periodically --- according to some key. Rather than setting several different alphabets, the cryptographer would use the Vigenere square. Here's the idea. For the given key word "FIRST", encrypt each letter of the message taken in the left-most column to the letter in the keyword-letter column. Thus, the first five letters of the message use the alphabets corresponding the the "F", "I", "R", "S", and "T" columns. So, the Vigenere code with this keyword is really five Caesar shifts used in a cyclical fashion. Decription is carried out working backwards from the keyword-columns to the left-most column. Because we are really using five alphabets, the Vigenere encryption is sometimes called a polyalphabetic (many + alphbets) code.
Public classThreefish
Threefish is a tweakable block cipher designed as part of the Skein hash function, an entry in the NIST hash function competition. Threefish uses no S-boxes or other table lookups in order to avoid cache timing attacks its nonlinearity comes from alternating additions with exclusive ORs. In that respect, it's similar to Salsa20, TEA, and the SHA-3 candidates CubeHash and BLAKE. Threefish and the Skein hash function were designed by Bruce Schneier, Niels Ferguson, Stefan Lucks, Doug Whiting, Mihir Bellare, Tadayoshi Kohno, Jon Callas, and Jesse Walker.
Public classThreefishTransform
Transformation for ThreeFish encryption algorithm
Public classXOR
XOR simple encryption algorithm. XOR, also know as Exclusive OR, is a bitwise operator from binary mathematics. The XOR operator returns a 1 when the value of either the first bit or the second bit is a 1. The XOR operator returns a 0 when neither or both of the bits is 1.

Interfaces

  InterfaceDescription
Public interfaceIStreamAlgorithm
IStreamAlgorithm. This is the base interface for file based/stream based encryption.

Enumerations

  EnumerationDescription
Public enumerationSupportedStreamAlgorithms
Available symmetric encryption algorithms.
Public enumerationSupportedTextAlgorithms
Supported Text Encryption Algorithms
Public enumerationTextAlgorithmType
The type of text algorithm
Public enumerationThreefishTransformType