× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hello,

I've been struggling with this for a few days and cannot seem to get it right. Although this is a java question I'll start with a little background as to what's going on.

We have an RPG stored procedure that takes a string and either encrypts or decrypts it and returns the value for other applications/programs to use. This program functions correctly when called from another RPG or CL program. It uses the below code..

If Function = 'ENCRYPT';
EXEC SQL SET :ResultVarying = ENCRYPT_TDES(:InputVarying, :pw);
Endif;

If Function = 'DECRYPT';
EXEC SQL SET :ResultVarying = DECRYPT_CHAR(
cast(:InputVarying as char(5000) for bit data), :pw);
Endif;

Returns ResultVarying.

CREATE PROCEDURE x(
IN METHOD CHAR ( 7),
IN INSTR CHAR (5000),
OUT OUTSTR CHAR ( 5000),
OUT ERROR CHAR ( 50))
LANGUAGE RPGLE
NOT DETERMINISTIC
MODIFIES SQL DATA
EXTERNAL NAME x
PARAMETER STYLE GENERAL WITH NULLS

We have a java web application that invokes this procedure sending in a credit card number to be encrypted. The encrypted value is then inserted in a different file.

When I try to use a Prepared statement to insert this value the statement works, but the value inserted in the field is not correct. It looks like encrypted data, but it is not encrypted correctly. When I try to decrypt it from the RPG program in a green screen environment I get 'The data is not a result of a supported encryption function.' Somewhere the value is getting converted, but I don't know where. I don't know if it's through the procedure definition or through the jdbc prepared statement.

The field in the file is described by DDS as 32A with CCSID(65535).

I have tried a variety java code to try to get this to work with a prepared statement. The only way I could get it to insert without a data mismatch is by ..
String sql = new String("Insert into ncptest (counter, ccnum) " +
"Values(?, cast(? as char(32) for bit data)) with nc");
pStmt = conn.prepareStatement(sql);
pStmt.setInt(1, x);
pStmt.setObject(2, encryptedValue.getBytes(), java.sql.Types.CHAR);

Is there anything obvious that I'm doing wrong? I really appreciate any ideas. Thanks in advance for any help.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.