Git Product home page Git Product logo

entlibcryptocli's Introduction

EntLibCryptoCli

Build status release

Enterprise Library Cryptography Block CLI

Born out of a requirement to restore RijndaelManaged Symmetric keys from the command line while removing the manual use of the EntLibConfig.exe app. Why does that matter? The EntLibConfig.exe application is a desktop application with no command line support.

If you have an older application which depends on the Enterprise Library Cryptography Block and wish to run that application in an auto-scaling group, you will not be able to as the RijndaelManaged key is DPAPI protected and must be restored on each new computer it is used on. Before this CLI, that could only be done through a manual clickity-clickity-click-click app. Well unless you rolled your own of course :).

  • Input: A previously Archived (exported) key, the password for the exported key

  • Output: A new machine level DPAPI protected RijndaelManaged provider key.

Basic Use

Built-in help

Get general options and available commands:
EntLibCryptoCli --help

Get options for a specific command:
EntLibCryptoCli <command> --help

Note: help will always be shown if a command is not used correctly along with wrong or missing parameters.

Commands

Get version information:
EntLibCryptoCli --version

Archive a working DPAPI protected key so you may transfer it to another computer:
EntLibCryptoCli archivekey -k c:\pathto\keyfile.key -p Str@ongPw -a c:\path\archivefile.txt

Restore an archived key on a computer:
EntLibCryptoCli restorekey -a c:\path\archivefile.txt -k c:\path\restore\newkeyfile.key -p Str@ongPw

Generate a new key on a computer:
EntLibCryptoCli generatekey -k c:\path\restore\newkeyfile.key -p Str@ongPw

Basic Functionality Test

In the release package is a folder named TestKey. There is an exported (archived) key (ExportedKey.txt) located here which may be restored for testing encryption and decryption with the provided encrypted text.

Note: DO NOT use this key for your own projects! It is provided only as a convenience to allow you to to test the cli's functionality on your machine.

Process

After downloading the release from GitHub, unzip the file to c:\. For the sake of these instructions we will assume the release is in folder c:\EntLibCryptoCli. Since the location of the key is important to use it for encrypting and decrypting ensure it's exported to the TestKey folder as UseForVerificationOnly.key.

  1. From the command line ensure you're in the c:\EntLibCryptoCli folder
  2. Restore key to your computer.
    1. EntLibCryptoCli restorekey -a c:\EntLibCryptoCli\TestKey\ExportedKey.txt -k c:\EntLibCryptoCli\TestKey\UseForVerificationOnly.key -p p@ssw0rD

  3. Decrypt the test encrypted text: H8tpiA7eRcAT+V3qb9TD2nEYwoShvpPkfcwOtf8HP/28Tbh9Utznkf9VpG8qaAzzY2k+kxrnaZ821t3BsYwPNoRlw5x9Uf92BbWwioTnO2sA+guYR7vEXYtVrES/LEZ1ULrdOi90K/hFUiKmESNe2/A2SsYyZ+ocgh2pKUXLplY=
    1. EntLibCryptoCli decrypt -s H8tpiA7eRcAT+V3qb9TD2nEYwoShvpPkfcwOtf8HP/28Tbh9Utznkf9VpG8qaAzzY2k+kxrnaZ821t3BsYwPNoRlw5x9Uf92BbWwioTnO2sA+guYR7vEXYtVrES/LEZ1ULrdOi90K/hFUiKmESNe2/A2SsYyZ+ocgh2pKUXLplY=

    2. Output value will be legible if correct.
    3. A Message like, "The data is invalid", probably means the key is corrupt
    4. A message like, "Padding is invalid and cannot be removed", usually means the key has not been restored correctly on the computer it is being used on.
  4. If you like you may encrypt some text:
    1. EntLibCryptoCli encrypt -s "some text"
  5. The decrypt it again:
    1. EntLibCryptoCli decrypt -s LKFqWSVE3OsScUvgnuP7/KBJCqgmX2qtmJhfvWXz4ZebTYSHbINwrncX8Qmt29xt
      • Please note that your encrypted string WILL be different due to the way AES encryption work. Though this string will decrypt to the same value.

Troubleshooting

The biggest issue I have come across with the cli is testing the encryption and decryption. Since the library must be registered in app.config file there may be a version conflict depending on the current version pulled from NuGet.

To date no issues have been seen restoring provider keys.

entlibcryptocli's People

Contributors

brettski avatar henry-padilla avatar

Watchers

 avatar James Cloos avatar  avatar  avatar

entlibcryptocli's Issues

Add verbose messaging

For commands RestoreKey and ArchiveKey add a -v, --verbose option to display detailed errors. This will include full stack traces of exceptions, etc.

Add Key Export

Add command to export key so it may be transferred and restored on another computer

Text decryption

Add command to decrypt value using a restored key.

  • Input command line
  • output stdout

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.