com.jimischopp.msdpapi
Class MSDPAPIJava

java.lang.Object
  extended by com.jimischopp.msdpapi.MSDPAPIJava

public class MSDPAPIJava
extends java.lang.Object

A JNI wrapper around the MS DPAPI Encryption library. Encrypts/Decrypts strings using the Microsoft DPAPI library (in Crypt32.dll). This has the restriction that the original string must be decrypted on the same machine it was encrypted on, since the MSDPAPIJava library uses the Machine-level store.

To use this API (obviously only on Windows), simply place MSDPAPIJava.dll in your library path, and then include/call the static methods on this class. For example:

                System.out.println(com.jimischopp.msdpapi.MSDPAPIJava.CryptProtectData("lalafdsfds"));
 
would render something similar to:
                AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAA6cdt4K6RPUOd0SuEQ3rAIgQAAAAKAAAAVzJLRHVtbXkAAANmAACoAAAAEAAAAEP7/vnKVT6
 
and passing this long cypher-text to CryptUnprotectData would again yield the original "lalafdsfds".

Copyright 2004, James Schopp

Author:
James Schopp

Constructor Summary
MSDPAPIJava()
           
 
Method Summary
static java.lang.String CryptProtectData(java.lang.String clearText)
          Encrypts a string using the MS DPAPI Machine-level encryption key.
static java.lang.String CryptUnprotectData(java.lang.String cypherText)
          Unencrypts a cyphertext string using the MS DPAPI Machine-level encryption key.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MSDPAPIJava

public MSDPAPIJava()
Method Detail

CryptProtectData

public static java.lang.String CryptProtectData(java.lang.String clearText)
Encrypts a string using the MS DPAPI Machine-level encryption key.

Parameters:
clearText - the original clear text
Returns:
the encrypted text

CryptUnprotectData

public static java.lang.String CryptUnprotectData(java.lang.String cypherText)
Unencrypts a cyphertext string using the MS DPAPI Machine-level encryption key.

Parameters:
cypherText - the encrypted text
Returns:
the original clear text