Page 1 of 4 1 2 3 ... LastLast
Results 1 to 10 of 32

Thread: Data Encryption Business Function

  1. #1
    New Member smartguru's Avatar
    Join Date
    Mar 2007
    Location
    Makati Philippines
    Posts
    18

    Data Encryption Business Function

    Hi All,
    Anyone here did some business function on how to encrypt the parameter values? for example. Document number will send as input, then the output should be encrypted data. If you have a sample code for that, please send me a copy. I don't have experience in C++ as per the oracle B0800760 BFN is the sample bfn with encryption key, but hard to read for me since a have very minimal idea in C++. If anyone here can give some explanation or sample code with same function and small explanation of each procedures that will be very helpfull for me to solve my problem. btw, we are using E-one 8.10

    Thanks in advance.

    JD Edwards Xe, 8.9/8.11/8.12/9.0
    SQL 2000/2005/2008
    PeopleSoft - People Tool/SQR/SQF/App Engine
    MS Dyanmic AX

  2. #2
    Member
    Join Date
    Aug 2004
    Location
    USA
    Posts
    221

    Re: Data Encryption Business Function

    Tools Release 8.94 has introduced two new APIs jdeEncryptWKey and jdeDecryptWKey to perform encryption and decryption of data using the TripleDES encryption algorithm.

    I checked the API and Business functions guide and found details about the two APIs and examples of usage (attached). Hope that helps.
    Attached Files Attached Files

  3. #3
    New Member smartguru's Avatar
    Join Date
    Mar 2007
    Location
    Makati Philippines
    Posts
    18

    Re: Data Encryption Business Function

    Thanks, this is very usefull.
    JD Edwards Xe, 8.9/8.11/8.12/9.0
    SQL 2000/2005/2008
    PeopleSoft - People Tool/SQR/SQF/App Engine
    MS Dyanmic AX

  4. #4
    Member
    Join Date
    Dec 2000
    Location
    Dallas, TX
    Posts
    148

    Re: Data Encryption Business Function

    Does anyone know what the value of int eVPTripeDES from this sample code is suppose to be?

    type=eEVPTripleDES;

    Thanks
    Rob

  5. #5
    Senior Member craig_welton's Avatar
    Join Date
    Oct 2000
    Location
    Litchfield, CT
    Posts
    1,027

    Re: Data Encryption Business Function

    Based on JDEKDFN.H ...

    enum tagEncryptType {
    eDESInvalidType = 0,
    eEVPTripleDES = 1
    } ;

    so the value is 1
    Craig Welton
    PatWel Group Inc.
    http://www.patwel.com
    Home of the FREE JDE Object Browser, JDETrace, NERDup and BusBuild+ Tools

    E1 9.0 8.98.4.2 Wintel SQL 2008
    E1 9.2 9.2.1.4 iSeries

  6. #6
    Member
    Join Date
    Dec 2000
    Location
    Dallas, TX
    Posts
    148

    Re: Data Encryption Business Function

    Pretty smart. I missed that one.

    One more problem I'm running into. Since I want to create a BSFN that has inputs and outputs and I want to control what to encrypt and decrypt. When the data is encrypted in the BYTE variable. i.e. BYTE EncryptedData.

    How can I move that BYTE variable into a JCHAR variable or vise versa
    jdeStrcpy((BYTE *)(&EncryptedData),
    (JCHAR *) &lpDS->szParameterStringInput);

    Cannot seem to be able to typecast the BYTE var and get a proper compile. I'm missing something since I normally do not work with BYTE Vars.

    Thanks
    Rob

  7. #7
    Senior Member craig_welton's Avatar
    Join Date
    Oct 2000
    Location
    Litchfield, CT
    Posts
    1,027

    Re: Data Encryption Business Function

    Rob,

    It may be cleanest to allocate a BYTE buffer, peform the encryption into that buffer, then memcpy that buffer to your output string.

    For decryption, allocate a BYTE buffer, memcpy the encrypted data (which is in the form of a JCHAR array in your BSFN datastructure) into the byte array and run the decrypt API.

    After a quick test, this seems to work without buffering...
    <font class="small">Code:</font><hr /><pre>
    if (lpDS-&gt;cAction == _J('E'))
    {
    iInSize = jdeStrlen(lpDS-&gt;szString);
    jdeEncryptWKey((BYTE*)lpDS-&gt;szEncrypted, &iOutSize, lpDS-&gt;szString, iInSize, lpDS-&gt;szKey, jdeStrlen(lpDS-&gt;szKey), 1);

    }
    if (lpDS-&gt;cAction == _J('D'))
    {
    iInSize = jdeStrlen(lpDS-&gt;szEncrypted)*sizeof(JCHAR);
    jdeDecryptWKey(lpDS-&gt;szString, &iOutSize, (BYTE*)lpDS-&gt;szEncrypted, iInSize, lpDS-&gt;szKey, jdeStrlen(lpDS-&gt;szKey), 1);
    }
    </pre><hr />


    Craig
    Craig Welton
    PatWel Group Inc.
    http://www.patwel.com
    Home of the FREE JDE Object Browser, JDETrace, NERDup and BusBuild+ Tools

    E1 9.0 8.98.4.2 Wintel SQL 2008
    E1 9.2 9.2.1.4 iSeries

  8. #8
    Senior Member
    Join Date
    Mar 2004
    Location
    Fort Worth, Texas
    Posts
    1,582

    Re: Data Encryption Business Function

    Another thing to remember, if you are encrypting strings (or any data type for that matter), you are not going to get a string back, you are going to simply get back an encrypted byte array. If you want a string representation of your encrypted data you will most likely have to base64 encode/decode the encrypted byte array.
    Brian Oster
    Application Development Manager
    E1: 9.0 (TR9.1.5.1) / 9.2 (TR9.2.2.2)
    JAS/BSSV: Weblogic 12.1.2 / Weblogic 12.2
    ES: Win2008 / Win2016
    DB: MSSQL 2014 / 2016
    WebDev Client: Win7Pro / Win10Pro

  9. #9
    Member
    Join Date
    Dec 2000
    Location
    Dallas, TX
    Posts
    148

    Re: Data Encryption Business Function

    Craig,

    I got everything in the business function working with parms and the whole deal. Everything works great when moving data around in an application for testing. I increased my database field sizes to account for the new encrypted field lenght. But now I just realized when passing the encrypted data value back to the application for database update i.e. "ᣋ㟖". I cannot seem to perform a file update with that value from inside the form application.

    Do I need to setup something special in data dictionary for these kind of fields?

    See logs below..

    Thanks
    Rob

    sql update from jdedebug.log. I'm not sure why the characters are all funny.

    UPDATE XXDTA810/F5542199 SET CE3C='' WHERE (CEDOCO = 7832.000000)


    jde.log


    5024/5064 FOREIGN_THREAD Fri Jun 04 15:58:33.353029 Jdbodbc.c8337
    ODB0000163 - wSQLExecute failure. rc=-1

    5024/5064 FOREIGN_THREAD Fri Jun 04 15:58:33.353031 Jdbodbc.c8337
    ODB0000164 - STMT:00 [22018][30200] [IBM][iSeries Access ODBC Driver]Column 8: CWBNL0107 - Converted 8 bytes, 4 errors found beginning at offset 0

    5024/5064 FOREIGN_THREAD Fri Jun 04 15:58:33.353033 Jdbodbc.c8337
    ODB0000164 - STMT:01 [22018][30019] [IBM][iSeries Access ODBC Driver]Error in assignment.

    5024/5064 FOREIGN_THREAD Fri Jun 04 15:58:33.353036 Jdb_drvm.c982
    JDB9900401 - Failed to execute db request

    5024/5064 FOREIGN_THREAD Fri Jun 04 15:58:33.353038 Jdb_exet.c3007
    JDB3600011 - Failed to perform Update for F5542199

  10. #10
    Senior Member
    Join Date
    Mar 2004
    Location
    Fort Worth, Texas
    Posts
    1,582

    Re: Data Encryption Business Function

    Like I said in an earlier post in this thread. If you want a string representation of the encrypted data you will need to base64 encode the encrypted byte data.

    If you encrypt a string with DES or triple DES, you won't get a string back. You will get back a bunch of encrypted bytes - this is not a valid string value. You have to then base64 encode the encrypted bytes which will give you an ascii string which you can then persist in a database or do what ever with. When you need to decrypt it, you will need to base64 decode the string which will give you your encrypted bytes and then decrypt the byte data which will result in your original string.

    Oh, and to store the base64 encoded data will require even a larger field because 3 bytes results in 4 base64 encoded bytes.
    Brian Oster
    Application Development Manager
    E1: 9.0 (TR9.1.5.1) / 9.2 (TR9.2.2.2)
    JAS/BSSV: Weblogic 12.1.2 / Weblogic 12.2
    ES: Win2008 / Win2016
    DB: MSSQL 2014 / 2016
    WebDev Client: Win7Pro / Win10Pro

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
The legal restrictions and terms of use applicable to this site are available here.
Use of this site signifies your agreement to the terms of use.
JDELIST is NOT affiliated with JD Edwards® & Company, Oracle or Peoplesoft. Contents of this site are neither endorsed nor approved by JD Edwards® & Company and, or Oracle.