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: 264

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: 2453
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

Active Member


Joined: 29 Apr 2008
Posts: 932
Location: Maryland

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 Any examples of calling FTP from REXX? CLIST & REXX 1
No new posts SummeRx: a new framework for REXX z/OS CLIST & REXX 6
No new posts A command to change LRECL of an exist... JCL & VSAM 7
No new posts Using REXX to access SDSF; What am I ... CLIST & REXX 38
No new posts Calling Assembler from REXX PL/I & Assembler 5
Search our Forums:

Back to Top