Posted: 3/17/2009 9:10:05 AM EDT
|
First: I'm not a Java developer. I don't play one on TV and have never stayed at a Holiday Inn Express. I'm just too stupid to understand it for some reason.
I work on a legacy project that uses PowerBuilder. A guy on the project is making a Java utility that will allow us to take a file and SFTP it up to a server and I need to pass it a username/password. We are trying to come up with an encryption that both systems can use, however PB is stuck with the only thing I've gotten to work yet which is the Microsoft CryptoAPI using the MS Strong Cryptographic Provider. He can't figure out how to implement the same thing in Java. Apparently in 1.6 they added a new package specifically to use with the MS API, but most if not all the examples he can find to help understand its use deal with the keystore for web pages. Anyone ever dealt with this and know of or can generate a quick example of decrypting an encrypted string with just that string and a pass phrase? No keystore or public/private combo outside of what you might need to instantiate the environment. |
|
Powerbuilder has what it calls external functions in which you spell out the interface to a resource, in this case Microsoft's advapi32.dll. So these are Microsoft functions being called on by Powerbuilder.
The code I have is an object someone else wrote in which I am re-using. The provider type is "Microsoft Strong Cryptographic Provider." It uses the MS Functions: CryptAcquireContext, CryptCreateHash, CryptHashData, CryptDeriveKey, CryptEncrypt. There are a number of constants defined, most of which are ulongs which at a glance mean nothing to me: // constants for cypto api Constant String KEY_CONTAINER = "MyKeyContainer" Constant ULong PROV_RSA_FULL = 1 Constant ULong CALG_MD5 = 32771 Constant ULong CALG_RC4 = 26625 Constant ULong ENCRYPT_ALGORITHM = CALG_RC4 Constant ULong CRYPT_NEWKEYSET = 8 Constant ULong ERROR_MORE_DATA = 234 The ENCRYPT_ALGORITHM, CALG_MD5 and RC4 are used in the MS function calls. |