× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Rishi,

1) There are a couple of ways to do this:
    a. Use a CL program to call your encryption program and have it do the CHGJOB before calling your program.
    b. Have your program call QCMDEXC, passing it the CHGJOB command and the command length. Make sure it does this before the encrypt command.

2) You can lookup the SQLCODE online many places. I found it at https://www.ibm.com/support/knowledgecenter/en/SSEPEK_11.0.0/codes/src/tpc/n204.html and that tells you the problem: "-204nameIS AN UNDEFINED NAME".

Then I looked up the decrypt command at https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_71/db2/rbafzscadecrypt.htm
 and the problem is that decrypt_AES is not a valid function. For a character field (which is what field enc is), use decrypt_char.

--
*Peter Dow* /
Dow Software Services, Inc.
909 793-9050
petercdow@xxxxxxxxx <mailto:petercdow@xxxxxxxxx>
pdow@xxxxxxxxxxxxxx <mailto:pdow@xxxxxxxxxxxxxx> /

On 9/23/2019 3:07 PM, Rishi Seth wrote:
thanks much ! it\s seems to be encrypted and sql code value is also 0 now.
but still had below queries:-
1) eachtime i run my program do i need to run this command as well? chgjob
sysval(37) can't it be automated? secondly the moment after i ran command
chgjob sysval(37) and then ran this command DSPSYSVAL SYSVAL(QCCSID) then
it still showed previous value as '65535'. but when i ran the program
encryption was done and sql code value was also 0 now but at the same time
when i am trying to decrypt it it's not getting decrypted please see below
code for the same now and in below code second SQLCODE Value is coming as
-204 and decrypted value is coming same as encrypted which ideally should
not be the case right?
so could someone please advise accordingly ?

*************** Beginning of data *************************************
denc s 50
dpsw s 31
inz('6-9d15-ec98bcc81ec4275OIM1TS7LI+
D ')
Dtext s 13

c eval text = 'whatever text'
/free
exec SQL Set :enc = encrypt_AES(:text,:psw);
DSPLY SQLCODE;
DSPLY enc;
exec SQL Set :enc = decrypt_AES(:enc,:psw);
DSPLY SQLCODE;
DSPLY enc;
eval *inlr=*on;

Thanks

On Mon, Sep 23, 2019 at 7:01 PM Rob Berendt <rob@xxxxxxxxx> wrote:

Hey Rishi, it would be really sweet if you let us know if that solved your
issue.

Rob Berendt
--
IBM Certified System Administrator - IBM i 6.1
Group Dekko
Dept 1600
Mail to: 2505 Dekko Drive
Garrett, IN 46738
Ship to: Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com


-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Rob
Berendt
Sent: Monday, September 23, 2019 11:08 AM
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: RE: Regarding Decryption of AES128 encrypted data in RPGLE and
query regarding CRC 32

I can perfectly duplicate your situation at last!
I know EXACTLY what is wrong!

Your job CCSID is 65535.

Many of us in the United States have ran the following CHGSYSVAL
SYSVAL(QCCSID) VALUE(37) That may require more study before implementing in
your shop.
So, to test, try this
CHGJOB CCSID(37)
Or some more appropriate regional value.
And try again.
To duplicate your error I ran
CHGJOB CCSID(65535)
And then I got
call rishi
Parameter 2 of function ENCRYPT_AES not valid.
Argument 02 of function ENCRYPT_AES not valid.
DSPLY 171-
DSPLY ██02██ENCRYPT_AES██*N██*N██1████████████████████████
DSPLY
Cause . . . . . : Parameter 2 specified in function ENCRYPT_AES is not
valid
for use for reason code 6. The reason codes and their meanings follow:

6 -- Parameter must be a valid CCSID.

This is clearly spelled out in the manual:
password-string
An expression that returns a character string value with at least 6 bytes
and no more than 127 bytes. The expression must not be a CLOB and the CCSID
of the expression must not be 65535. The value represents the password used
to encrypt the data-string. If the value of the password argument is null
or not provided, the data will be encrypted using the ENCRYPTION PASSWORD
value, which must have been set using the SET ENCRYPTION PASSWORD statement.

Running with a CCSID of 65535 is the default IBM gives you to give you
ENDLESS grief and encourage you to pick an appropriate value for the system
value QCCSID.


Rob Berendt
--
IBM Certified System Administrator - IBM i 6.1 Group Dekko Dept 1600 Mail
to: 2505 Dekko Drive
Garrett, IN 46738
Ship to: Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com


-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of
Rishi Seth
Sent: Monday, September 23, 2019 10:41 AM
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: Regarding Decryption of AES128 encrypted data in RPGLE and
query regarding CRC 32

CAUTION: This email originated from outside of the organization. Do not
click links or open attachments unless you recognize the sender and know
the content is safe.


yes your code displays same value -171 and for encrypted value as blanks
only.

On Mon, Sep 23, 2019 at 4:34 PM Rob Berendt <rob@xxxxxxxxx> wrote:

Just to clarify, by same result you mean sqlcode = -171?

Rob Berendt
--
IBM Certified System Administrator - IBM i 6.1 Group Dekko Dept 1600
Mail to: 2505 Dekko Drive
Garrett, IN 46738
Ship to: Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com


-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of
Rishi Seth
Sent: Monday, September 23, 2019 10:20 AM
To: Midrange Systems Technical Discussion
<midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: Regarding Decryption of AES128 encrypted data in RPGLE
and query regarding CRC 32

CAUTION: This email originated from outside of the organization. Do
not click links or open attachments unless you recognize the sender
and know the content is safe.


tried below still the same result:-
denc s 50
dpsw s 31 inz('6-9d15-ec98bcc81ec4275OIM1TS
D ')
Dtext s 13

c eval text = 'whatever text'
/free
exec SQL Set :enc = encrypt_AES(:text,:psw);
DSPLY SQLCODE;
DSPLY enc;
eval *inlr=*on;

On Mon, Sep 23, 2019 at 4:11 PM Rob Berendt <rob@xxxxxxxxx> wrote:

Number three below is probably the biggest culprit. I'll give you
the rest as stuff you messed up on in copy/paste to obfuscate the code.

One, You never defined the variable TEXT.
Two, you forgot a semicolon at the end of
Text = 'Whatever Text'
Three you forgot the colon in front of Text and PassWord in
Encrypt_AES(Text, PassWord).
Four you forgot the semicolon at the end of inz('yourPassWord')

Change this:
DCL-S Encrypted VarChar(256);
DCL-S Password VarChar(15) inz('yourPassWord')

Text = 'Whatever Text'
Exec SQL Set :Encrypted = Encrypt_AES(Text, PassWord);
EVAL *INLR=*ON;

To:
**free
DCL-S Encrypted VarChar(52); // I only changed this to 52 to test
using DSPLY DCL-S Password VarChar(15) inz('yourPassWord'); DCL-S
Text VarChar(80);
Text = 'Whatever Text';
Exec SQL Set :Encrypted = Encrypt_AES(:Text, :PassWord);
Dsply SQLCODE;
Dsply Encrypted;
*inlr = *on;

Rob Berendt
--
IBM Certified System Administrator - IBM i 6.1 Group Dekko Dept 1600
Mail to: 2505 Dekko Drive
Garrett, IN 46738
Ship to: Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com


-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf
Of Rishi Seth
Sent: Monday, September 23, 2019 3:44 AM
To: Midrange Systems Technical Discussion
<midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: Regarding Decryption of AES128 encrypted data in RPGLE
and query regarding CRC 32

CAUTION: This email originated from outside of the organization. Do
not click links or open attachments unless you recognize the sender
and know the content is safe.


Tried this code but it's not working and giving below errors while
compilation itself.

**free
DCL-S Encrypted VarChar(256);
DCL-S Password VarChar(15) inz('yourPassWord')

Text = 'Whatever Text'
Exec SQL Set :Encrypted = Encrypt_AES(Text, PassWord);
EVAL *INLR=*ON;

*********
M e s s a g e S u m m a r y

Msg id Sv Number Message text

RNF0607 00 1 Text is skipped to recover from the previous error.

RNF7031 00 36 The name or indicator is not referenced.

RNF0312 20 1 A right parenthesis is expected but is not found.

RNF0633 20 1 An unexpected right parenthesis was encountered;
right
parenthesis is ignored.

RNF3308 20 10 Keyword name is not valid; the keyword is ignored.

* * * * * E N D O F M E S S A G E S U M M A R Y * * *
* *




On Mon, Sep 23, 2019 at 8:14 AM Rishi Seth <rishiseth99@xxxxxxxxx>
wrote:
So similarly will it work för decryption?

On Fri, Sep 20, 2019, 18:10 Birgitta Hauser
<Hauser@xxxxxxxxxxxxxxx>
wrote:

Dear Rishi,

do you read the answers you get?
I send you already yesterday the SQL Solution.
Here again the (embedded) SQL Source code (and don't forget to
change your source attribute to SQLRPGLE)

DCL-S Text VarChar(20);
DCL-S Encrypted VarChar(256);
DCL-S Password VarChar(15) inz('yourPassWord')

Text = 'Whatever Text'
Exec SQL Set :Encrypted = Encrypt_AES(Text, PassWord);

Mit freundlichen Grüßen / Best regards

Birgitta Hauser

"Shoot for the moon, even if you miss, you'll land among the stars."
(Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not
training them and keeping them!"
„Train people well enough so they can leave, treat them well
enough so they don't want to.“ (Richard Branson)


-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On
Behalf Of Rishi Seth
Sent: Freitag, 20. September 2019 15:11
To: Midrange Systems Technical Discussion
<midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: Regarding Decryption of AES128 encrypted data in
RPGLE and query regarding CRC 32

c/exec sql
c+ Declare c1 scroll cursor for
c+ select encrypt ('abcde','k1',1) FROM lib1/FL1
C/END-EXEC

Message ID . . . . . . : SQL0104 Severity . . . . . . . :
30
Message type . . . . . : Diagnostic



Message . . . . : Token ,1 was not valid. Valid tokens: ) ,.

Cause . . . . . : A syntax error was detected at token ,1. Token
,1
is
not
a valid token. A partial list of valid tokens is ) ,. This
list assumes

that the statement is correct up to the token. The error may
be earlier in
the statement, but the syntax of the statement appears to be
valid up to

this point.

Recovery . . . : Do one or more of the following and try the
request
again:
-- Verify the SQL statement in the area of the token ,1.
Correct the

statement. The error could be a missing comma or quotation
mark, it could
be a misspelled word, or it could be related to the order of
clauses.
-- If the error token is <END-OF-STATEMENT>, correct the SQL
statement

because it does not end with a valid clause.




On Fri, Sep 20, 2019 at 1:35 PM Rob Berendt <rob@xxxxxxxxx> wrote:

Let me find you a more applicable link:
https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/db2/rb
af zs cal e.htm Look up the various encrypt/decrypt functions
there.

First of all, you are trying to use a SQL function, NOT a RPG
function.
So you have to use "imbedded sql".
If you know nothing about imbedded SQL in RPG you are probably
better off asking on the RPG list. They should be able to give
you a couple of RTFM links.

There is probably a way to do the encrypt/decrypt outside of RPG.
One method which comes to mind is to build an index or view
over the file which does the encrypting/decrypting for you
before
returning it to RPG.
Rob Berendt
--
IBM Certified System Administrator - IBM i 6.1 Group Dekko Dept
1600 Mail to: 2505 Dekko Drive
Garrett, IN 46738
Ship to: Dock 108
6928N 400E
Kendallville, IN 46755 http://www.dekko.com


-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On
Behalf Of Rishi Seth
Sent: Thursday, September 19, 2019 11:41 PM
To: Midrange Systems Technical Discussion
<midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: Regarding Decryption of AES128 encrypted data in
RPGLE and query regarding CRC 32

CAUTION: This email originated from outside of the organization.
Do not click links or open attachments unless you recognize the
sender and know the content is safe.


I äm trying to use it as it's advised on below link but so far
have been unable to encrypt key in below program due to error
mentioned
previously.

https://www.ibm.com/support/knowledgecenter/en/SSULQD_7.1.0/com.i
bm .nz .sqltk.doc/r_sqlext_encrypt_decrypt.html

Thanks.


On Friday, September 20, 2019, Rishi Seth <rishiseth99@xxxxxxxxx>
wrote:
But i need to encrypt it that is why function is used.

On Friday, September 20, 2019, Sam_L <lennon_s_j@xxxxxxxxxxx>
wrote:
This compiles except for the error "The name or indicator
ENCRYPT is not defined. "

dt1 s 50 inz('abcde')
dt2 s 50
dk s 50
inz('16-9d15-ec98bcc81ec4275OI
M1TI')
d************* I')
C EVAL T2= ENCRYPT(t1:k:1)

C T2 DSPLY
C EVAL *INLR=*ON

Sam


On 9/19/2019 3:19 PM, Rishi Seth wrote:

Hi,

It's RPGLE program now after putting colons it's giving error
of
'**RNF7503
30 1 Expression contains an operand that is not defined.'
this
error
is at below code's line no. 6*

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L)
mailing list To post a message email:
MIDRANGE-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription
related questions.

Help support midrange.com by shopping at amazon.com with our
affiliate
link: https://amazon.midrange.com

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L)
mailing list To post a message email:
MIDRANGE-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our
affiliate
link: https://amazon.midrange.com
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L)
mailing list To post a message email:
MIDRANGE-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our
affiliate
link: https://amazon.midrange.com

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L)
mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our
affiliate
link: https://amazon.midrange.com

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L)
mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our
affiliate
link: https://amazon.midrange.com

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx To
subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx To
subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx To
subscribe,
unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com




---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.