Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


July 19, 2004

Access Denied: A Basic File Encryption Tool

RSS
Subscribe to Windows IT Pro | See More Security Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

I need a basic file encryption tool so that I can FTP and email files to business partners with whom no VPN is available. Does Windows provide any built-in utilities for encrypting files?

You apparently already realize that Encrypting File System (EFS) won't help you because EFS protects files while they're on your hard disk but decrypts them before they're transmitted. No built-in commands are available, but a COM interface called CAPICOM.dll provides easy-to-use, high-level access to Windows' CryptoAPI. Moreover, sample scripts that use the interface and let you encrypt and decrypt files from the command prompt are available in the Microsoft Platform Software Development Kit (SDK). These VBScript scripts are easy to modify, although you probably won't need to change them. You can learn more about CAPICOM at http://www.microsoft.com/msdownload/platformsdk/sdkupdate/default.htm?p=/msdownload/platformsdk/sdkupdate/psdkredist.htm, and you can download the SDK from http://www.microsoft.com/msdownload/platformsdk/sdkupdate.

After you install the SDK, look in the C:\Program Files\Microsoft SDK\Samples\security\capicom\vbs folder. Two scripts, cencrypt.vbs and cdecrypt.vbs, let you encrypt and decrypt a file from the command line, respectively. You can specify the password from which the encryption key is generated, the encryption algorithm, and the key length, as well as the input and output file names. To get help for either utility, simply enter the command followed by the -? parameter. The following sample command uses Advanced Encryption Standard (AES) to encrypt a file called transactions.txt:

cscript cencrypt.vbs encrypt
  -alg AES -length MAX
  transactions.txt
  e-transactions.txt
  sk343jf92k3j43023hgsl

To decrypt e-transactions.txt to a file named d-transactions.txt, use the command

cscript cencrypt.vbs decrypt
  e-transactions.txt

d-transactions.txt

sk343jf92k3j43023hgsl

The only gotcha with cencrypt.vbs is that it works only on text files--it doesn't handle other files, such as spreadsheets, databases, or files that contain non-ASCII characters. You can work around this limitation simply by converting the file to Base64-encoded format before you encrypt it, then backing out of Base64 encoding after you decrypt the file.

A public-domain utility called base64 can help; the utility is available at http://www.fourmilab.ch/webtools/base64. Written by John Walker, one of the original authors of AutoCAD, the base64 utility is simple and works well. The example below illustrates how to use Cencrypt and Base64 together.

base64 /e transactions.db
  b64-transactions.db
cscript cencrypt.vbs encrypt 
  -alg AES -length MAX
  b64-transactions.txt
  e-transactions.txt
  sk343jf92k3j43023hgsl
cscript cencrypt.vbs decrypt
  e-transactions.txt
  b64-transactions.txt
  sk343jf92k3j43023hgsl
base64 /d b64-transactions.db
  transactions.db

After running the commands, you can use the Comp command to verify that the original file (transactions.db) and the decrypted file (d-transactions.db) match.

To use Cencrypt on a computer, simply ensure that Windows Script Host (WSH) is installed and register CAPICOM.dll. WSH is installed by default on most Windows systems. To register CAPICOM.dll, simply install the downloaded file in %winroot% and run the command

regsvr32 capicom.dll

End of Article



Reader Comments

You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
WinInfo Short Takes: Week of November 23, 2009

An often irreverent look at some of the week's other news, including some post-PDC some soul searching, a Google Chrome OS announcement and a Microsoft response, Windows 7 off to a supposedly strong start, the Jonas Brothers and Xbox 360, and so much more ...

2009 Windows IT Pro Editors' Best and Community Choice Awards

Picking a favorite product from an impressive crowd of competitive offerings is never an easy task, and such was the case with our Editors' Best and Community Choice awards this year. ...

Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...


Security Whitepapers Reducing the Costs and Risks of Branch Office Data Protection

Solving Desktop Management Challenges in Healthcare

Solving Desktop Management Challenges in Education

Related Events Introduction to Identity Lifecycle Manager "2"

SQL Server Security: How to Secure, Monitor & Audit Your Databases

Protecting Mobile Users' Data

Check out our list of Free Email Newsletters!

Security eBooks Spam Fighting and Email Security for the 21st Century

Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

Related Security Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement