IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Encoding using rexx


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Sat Sep 08, 2018 1:05 am
Reply with quote

Dear all,

I have to write an rexx program to encrpyt a sequential file. Using similar logic mentioned in the below code.
Code:

/********REXX*******/
say 'The no to be encrypt is 1101:'
a=1101
say 'The pwd to be embeded is 1001:'
pwd=1001
c=bitxor(a,pwd)
say 'The encrypted value is:' c
d=bitxor(c,pwd)
say 'The decrypted value is:' d
exit


I got the decrypted value as 1101. But when i get the character from user(using pull) after converting character to hex and hex to binary then i xor with pwd i am not able to decrypt the data. I am not getting the original input from decrption.
The below is the code.
Please let me know how to fix this issue. Also is it possible to encrypt a file using above logic.
Code:

/******REXX******/
Say 'Enter the word to be encrypted:'
Pull a
Say 'Enter the pwd for encryption(1-8):'
Pull pwd
b=c2x(a)
c=x2b(b)
e=c2x(pwd)
f=x2b(e)
encrypt=bitxor(c,f)
Say 'encrypted word is:' encrypt
decrypt=bitxor(encrypt,pwd)
say 'decrpyted:' decrypt
exit
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Sat Sep 08, 2018 2:06 am
Reply with quote

Code:
decrypt = bitxor(encrypt,b_pwd)
say 'decrypted:' x2c(b2x(decrypt))

b_pwd is the same as 'f' in your code (why can you not use meaningful names?).

The result is in upper case because you did not PARSE your PULL.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Sat Sep 08, 2018 3:42 am
Reply with quote

As Nic mentioned above, you need RTFM

PULL ... is equivalent to PARSE UPPER PULL ...
In order to work with mixed case data you need to use PARSE PULL ...

If only you tried to trace what you're doing, you would discover this issue immediately. Instead of asking the forum.

RTFM, RTFM, and RTFM, forever(?)
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
Search our Forums:

Back to Top