Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Encoding using rexx

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 254

PostPosted: Sat Sep 08, 2018 1:05 am    Post subject: Encoding using rexx
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: 2090
Location: UK

PostPosted: Sat Sep 08, 2018 2:06 am    Post subject: Reply to: Encryption using rexx
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 User


Joined: 29 Apr 2008
Posts: 364
Location: Maryland

PostPosted: Sat Sep 08, 2018 3:42 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Can we call QMF proc from REXX ? batu544 CLIST & REXX 6 Fri Aug 03, 2018 11:03 am
No new posts REXX CGI - Hello World vasanthz All Other Mainframe Topics 4 Fri Jul 13, 2018 3:53 am
This topic is locked: you cannot edit posts or make replies. Rexx code to find greater then symobl... Bharath Vikraman CLIST & REXX 8 Tue May 29, 2018 9:40 am
No new posts Trap the jcl error message or maxcc i... ankita agarwal CLIST & REXX 5 Fri May 18, 2018 2:08 pm
No new posts Rexx command to open an another text ... Bharath Vikraman PC Guides & IT News 7 Sat May 12, 2018 4:34 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us