× 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.



In an interactive SQL session:

select encrypt('hola', 'clave mas larga') from sysibm.sysdummy1

Returns a string of "garbish".  Which is Ok, since encryption is supposed to return something that looks like random.

But for production I agree with you in using one of the specific functions that you listed below.

On 9/20/19 10:35 AM, Rob Berendt wrote:
Ok, this is weird. At first I was going to admonish you again for not selecting one of the ENCRYPT* functions I keep mentioning. However, there just may be an undocumented ENCRYPT function.
I used "Run SQL Scripts" and tried
VALUES EATDIRT ('abcde','k1', 1)
;
And I get: [SQL0204] EATDIRT in *LIBL type *N not found.

But if I try
VALUES ENCRYPT ('abcde','k1', 1)
I get: [SQL0171] Argument 3 of function ENCRYPT not valid. Cause . . . . . :   The data type, length, or value of argument 3 of function ENCRYPT specified is not valid. Recovery  . . . :   Refer to the DB2 for IBM i SQL Reference topic collection in the Database category in the IBM i Information Center for more information on scalar functions. Correct the arguments specified for the function. Try the request again.

None of the ENCRYPT* family of functions appear in QSYS2.SYSFUNCS or in SYSIBM.SQLFUNCTIONS.

Now look at the documentation for these three functions:
ENCRYPT_AES
ENCRYPT_RC2
ENCRYPT_TDES
In all of these the third parameter is optional. The third parameter is not numeric. It is:
hint-string
An expression that returns a character string value with up to 32 bytes that will help data owners remember passwords (For example, 'Ocean' is a hint to remember 'Pacific').

To avoid this error:
[SQ20144] Encryption password length not valid. Cause . . . . . :   The length of the encryption password must be from 6 to 127 characters.
I changed your example from
VALUES ENCRYPT ('abcde','k1')
To
VALUES ENCRYPT ('abcde','ihateohiostate')
;
And that actually works.

Now let's try the hint string:
VALUES ENCRYPT ('abcde', 'ihateohiostate', 'gomichigan')
This also works.

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

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

And see if that works.
Caveat: I tend to avoid undocumented functions.

Rob Berendt

-- Este e-mail fue enviado desde el Mail Server del diario ABC Color -- -- Verificado por Anti-Virus Corporativo Symantec --

As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.