I study z/OS and REXX and now have code, which takes public and private keys from MY.DATA.SET (PUBLIC, PRIVATE) and encrypts the message (MSG):
"ALLOC FI(pubkey) DA('MY.DATA.SET(PUBLIC)') SHR REUSE"
"ALLOC FI(prikey) DA('MY.DATA.SET(PRIVATE)') SHR REUSE"
"ALLOC FI(msgin) DA(‘MY.DATA.SET(MSG)') SHR REUSE"
"ALLOC FI(msgout) DA(*) SHR REUSE"
"EXECIO 1 DISKR pubkey (STEM pub. FINIS"
"EXECIO 1 DISKR prikey (STEM pri. FINIS"
"EXECIO * DISKR msgin (STEM msg. FINIS"
"EXECIO 0 DISKW msgout (STEM enc_msg. OPEN"
enc_msg.1 = pub.1
"EXECIO 1 DISKW msgout (STEM enc_msg. "
do i=1 to msg.0
do j=1 to length(msg.i)
letter.j = substr(msg.i,j,1)
encrypt.j = translate(letter.j,pri.1,pub.1)
end
call write_encrypted_line
end
"EXECIO 0 DISKW msgout (FINIS"
"FREE FI(pubkey)"
"FREE FI(prikey)"
"FREE FI(msgin)"
"FREE FI(msgout)"
exit 0
write_encrypted_line:
charout = ''
newchar = ''
do j=1 to length(msg.i)
newchar = encrypt.j
charout = charout||newchar
end
enc_msg.1 = charout
"EXECIO 1 DISKW msgout (STEM enc_msg. "
return
And I'd like to transfer it to DEsrypting code, which can DEcrypt the encrypted result from above (the result is stored by name MSGEN) to normal text, using, of course, same key-pair. Please, help: what should I change in my encpypring code to make it decrypting? The line
"ALLOC FI(msgin) DA(‘MY.DATA.SET(MSGEN)') SHR REUSE"
is already changed (MSG->MSGEN)
Thanks for any all help and response!
Without knowing what your keys are I think you need to reverse the keys in your TRANSLATE line.
http://www.ibm.com/support/knowledgecenter/SSLTBW_2.1.0/com.ibm.zos.v2r1.ikja300/transl.htm