CryptoService provides one-way hash and two-way encryption and decryption services.
In order to run CryptoService console app, a configuration file – Aliencube.CryptoService.ConsoleApp.exe.config – must be setup beforehand.
AlienCryptoService.exe (/e|/d) /m:"TEXT" [/f:FILENAME] [/o:FILENAME]
/e Encrypt the text or text file.
/d Decrypt the text or text file.
/t:"[TEXT]" Text to encrypt or decrypt. It must be enclosed by double quotes.
/f:[FILENAME] Filename containing text to encrypt or decrypt.
/o:[FILENAME] Filename to store text encrypted or decrypted.
NOTE: /e and /d cannot be used at the same time.
In order to use CryptoService in your applications, simply copy Aliencube.CryptoService.dll to the application's /bin directory or reference Aliencube.CryptoService.dll to your application project.
Alternatively, you can download the library from NuGet. Its package URL is
.NET framework provides five different hash algorithms, MD5, SHA1, SHA256, SHA384 and SHA512. CryptoService supports all those hash algorithms.
var provider = HashProvider.SHA256 // Sets the hash algorithm to SHA256
var hashService = new HashService(provider); // Creates a new HashService instance
var input = "Hello World"; // Sets the input text to "Hello World"
var output = hashService.Hash(input); // Gets the hashed value to output
Console.WriteLine("Input: {0}", input);
Console.WriteLine("Output: {0}", output);
// Input: Hello World
// Output: pZGm1Av0IEBKARczz7exkNYsZb8LzaMrV7J32a2fFG4=Please note that CryptoService does not put salt for hashing. So it is your own responsibility to add any salt before hashing.
.NET framework provides five different symmetric algorithms, Aes, DES, RC2, Rijndael and TripleDES. CryptoService supports all those symmetric algorithms.
var provider = SymmetricProvider.Aes // Sets the symmetric algorithm to Aes
var symmetricService = new SymmetricService(provider); // Creates a new SymmetricService instance
symmetricService.Key = "KEY_VALUE"; // Sets the key value.
symmetricService.Vector = "VECTOR_VALUE"; // Sets the vector value.
var input = "Hello World"; // Sets the input text to "Hello World"
var encrypted = symmetricService.Encrypt(input); // Gets the encrypted value to encrypted
var decrypted = symmetricService.Decrypt(encrypted); // Gets the decrypted value to decrypted
Console.WriteLine("Input: {0}", input);
Console.WriteLine("Encrypted: {0}", encrypted);
Console.WriteLine("Decrypted: {0}", decrypted);
// Input: Hello World
// Encrypted: bdwO/5C8a+pliIoIXtuzfA==
// Decrypted: Hello WorldDepending on the symmetric algorithm chosen, the length of key and vector are different.
Aes: 32/16DES: 8/8RC2: 16/8Rijndael: 32/16TripleDES: 24/8
Please note that CryptoService does not put salt for encryption. So it is your own responsibility to add any salt before encryption.
CryptoService is released under the MIT License.
The MIT License (MIT) Copyright (c) 2013 aliencube.org
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.