View previous topic :: View next topic
|
Author |
Message |
Bob Ream
New User
Joined: 05 Nov 2008 Posts: 7 Location: RI
|
|
|
|
I'm new to this site and have searched in vain to find a solution to my little problem. I need to convert some data that is in ASCII.
The situation is I have ASCII field coming in, convert it to EBCIDIC and run it through some encription software, it comes back out as a PIC 9(16) with hex values of
3333333333333333
4444123456789012
I need to convert this to hex values:
44135791
44246802
I have tried moving it to a Comp, Comp-3 and Comp-4 field to no avail, any suggestions on how this may be done would be greatly appreciated. I've never run aything like this before.
regards, |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
I would rather do this in rexx than cobol. (or assembler).
I imagine Bill will be along in a while and whip up one of his COBOL solutions.
Talk about bit fiddeling. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
run it through some encription software, it comes back out as a PIC 9(16) |
Huh? Encryption software should be generating PIC X(16) values since, unless the encryption is explicitly limiting itself to an output range of values, any possible collating sequence value can be generated.
I suspect the COBOL code to get rid of the threes and pack the nybbles into bytes will be convoluted -- I'd much rather do something like that in Assembler (which could be a subroutine callable from the COBOL module). |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Bob,
Can the ZONE nibbles of each byte be discarded, regardless of their value and the NUMERIC nibbles can be in the range of a 4-Bit '0' thru a 4-Bit 'F'?
Regards,
Bill |
|
Back to top |
|
|
Bob Ream
New User
Joined: 05 Nov 2008 Posts: 7 Location: RI
|
|
|
|
Bill,
Can the ZONE nibbles of each byte be discarded, regardless of their value and the NUMERIC nibbles can be in the range of a 4-Bit '0' thru a 4-Bit 'F'?
Not sure. The values that I need are going into another software product and if I try and feed them the way they are it really messes things up. Since this is credit card data I really don't want to screw up someone's account....would not be a pretty picture. At this point I'm willing to try just about anything, including an assembler routine if that is the only possible way of doing this...of course then again I would have to learn assembler. |
|
Back to top |
|
|
Bob Ream
New User
Joined: 05 Nov 2008 Posts: 7 Location: RI
|
|
|
|
The encryption product is returning a pic 9(16) as described above, then I need to convert it so the next software product will take it in. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Bob,
Check if this will work for you....
Code: |
03 WS-XLATE-INPUT PIC X(016).
03 WS-XLATE-WORK PIC X(016).
03 WS-XLATE-OUTPUT PIC X(008).
03 WS-SUB PIC 9(008) BINARY.
03 WS-SUB-X REDEFINES WS-SUB
PIC X(004).
03 WS-PACKED PIC 9(017) PACKED-DECIMAL.
03 WS-PACKED-V9 REDEFINES WS-PACKED
PIC 9(016)V9 PACKED-DECIMAL.
03 WS-PACKED-X REDEFINES WS-PACKED
PIC X(009).
03 WS-DISPLAY PIC 9(017).
03 WS-DISPLAY-V9 REDEFINES WS-DISPLAY
PIC 9(016)V9.
03 WS-DISPLAY-X REDEFINES WS-DISPLAY
PIC X(017).
*
MOVE X'303132333435363738393A3B3C3D3E3F'
TO WS-XLATE-INPUT.
MOVE WS-XLATE-INPUT TO WS-XLATE-WORK.
MOVE ZERO TO WS-SUB.
MOVE 1 TO TALLY.
*
* EACH BYTE WILL TRANSLATE TO X'F0' THRU X'FF', WITH THE ZONE
* NIBBLE OF THE ORIGINAL DATA-BYTE DISCARDED. THE TRANSLATED
* ZONE NIBBLE IS DISCARDED DURING A 'PACK', WHEN THE DISPLAY-V9
* FIELD IS MOVED TO THE PACKED-V9 FIELD AND ONLY THE 4-BIT
* NUMERIC NIBBLES ARE RETAINED.
*
PERFORM UNTIL TALLY > LENGTH OF WS-XLATE-WORK
MOVE WS-XLATE-WORK (TALLY:1)
TO WS-SUB-X (4:)
COMPUTE WS-SUB = (WS-SUB * 16)
COMPUTE WS-SUB = (WS-SUB / 16)
MOVE LOW-VALUE TO WS-SUB-X (3:1)
ADD 240 TO WS-SUB
MOVE WS-SUB-X (4:) TO WS-XLATE-WORK (TALLY:1)
ADD 1 TO TALLY
END-PERFORM.
*
MOVE WS-XLATE-WORK TO WS-DISPLAY-X (1:16).
MOVE ZERO TO WS-DISPLAY-X (17:).
MOVE WS-DISPLAY-V9 TO WS-PACKED-V9.
MOVE WS-PACKED-X TO WS-XLATE-OUTPUT.
*
* THE RESULT IN WS-XLATE-OUTPUT WILL BE X'0123456789ABCDEF'
*
|
Regards,
Bill |
|
Back to top |
|
|
Bob Ream
New User
Joined: 05 Nov 2008 Posts: 7 Location: RI
|
|
|
|
Thanks, I'll give it a shot and let you know. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Bob,
In the above code -
Code: |
COMPUTE WS-SUB = (WS-SUB / 16)
MOVE LOW-VALUE TO WS-SUB-X (3:1)
|
Needs to be changed to -
Code: |
MOVE LOW-VALUE TO WS-SUB-X (3:1)
COMPUTE WS-SUB = (WS-SUB / 16)
|
Went too fast....
Regards,
Bill |
|
Back to top |
|
|
Bob Ream
New User
Joined: 05 Nov 2008 Posts: 7 Location: RI
|
|
|
|
Bill,
Looks like this will work, I am however off one byte, dropping the 1st postion and picking up the FF at the end. Here is the output displayed in hex.
4444123456789012
FFFFFFFFFFFFFFFF
4444123456789012
à..îÌ°..
4135791F
4246802F
I will have to play around with it and see if I can get it down.
Thank you for the assist. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Bob: at least you're not having to deal with PCI compliant encryption -- I spent a good part of last year dealing with that issue and it wasn't fun! |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Robert,
I'm dealing with this same issue in my shop as we speak. Did you have to interact with CyberSource in California or did you use someone else?
We're going live on 11 November and right now, I'm not overly optimistic.
Regards,
Bill |
|
Back to top |
|
|
Bob Ream
New User
Joined: 05 Nov 2008 Posts: 7 Location: RI
|
|
|
|
Robert,
I am dealing with encryption compliance now....what a pain. It is dealing with Mainframe calling unix, calling web server and back to mainframe also mixed in with C+ code. This all goes on in between 2 programs that are part of a package bought in 1996 and maintenance was dropped in 1999. Dealing with ASCII to EBCDIC conversions and back to ASCII then into one of the packaged programs that convert it back to EBCDIC.
My head hurts, I'm going home. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Bill: We wound up using ZIP-390 from Data/21 which supports field-level PCI-compliant encryption. The routines are called from COBOL batch, COBOL CICS, and batch SAS programs.
Bob: I hear you -- my head's hurting and I don't even deal with that mess! |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Bob,
Because I typically over engineer things some times , if you need to discard the ZONES, then the PACK will discard them for you, regardless of their value.
So, the perform loop may not be needed.
However, I am getting the resulting value of X'0123456789ABCDEF' in WS-PACKED-X (1:8) after all is said and done, with a X'0F' in byte-09.
Just make sure that you're using the "V9" numeric-fields as this makes a difference as well as make sure you apply the fix to the supplied-code, which I posted after the fact if you decide to keep the perform loop.
Regards,
Bill |
|
Back to top |
|
|
|