Giter Club home page Giter Club logo

cryptoservice's Introduction

CryptoService

CryptoService provides one-way hash and two-way encryption and decryption services.

Package Status

Getting Started – Console Application

In order to run CryptoService console app, a configuration file – Aliencube.CryptoService.ConsoleApp.exe.config – must be setup beforehand.

Usage

AlienCryptoService.exe (/e|/d) /m:"TEXT" [/f:FILENAME] [/o:FILENAME]

Parameters

/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.

Getting Started – CryptoService Library

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

Hash Service

.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.

Symmetric Service

.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 World

Depending on the symmetric algorithm chosen, the length of key and vector are different.

  • Aes: 32/16
  • DES: 8/8
  • RC2: 16/8
  • Rijndael: 32/16
  • TripleDES: 24/8

Please note that CryptoService does not put salt for encryption. So it is your own responsibility to add any salt before encryption.

License

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.

cryptoservice's People

Contributors

justinyoo avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

masallahozen

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.