A new concept AND free code? must be the season, Thanks Chuck!
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of CRPence
Sent: Friday, December 16, 2011 12:54 PM
To: midrange-l@xxxxxxxxxxxx
Subject: Re: Encryption for Dummies?
On 16-Dec-2011 10:21 , James Lampert wrote:
Gary Thompson wrote:
On 16-Dec-2011 08:35 , James Lampert wrote:
It seems that I'm going to need to encrypt a piddling 24-byte "OAuth
Consumer Secret" (one per installation, on the installation's
hardware).
Can anybody point me to some sample code for calling the
encryption/decryption APIs? I've now done HMAC-SHA1 signatures, with
an API call, but not actual encryption/decryption.
Can you get by with the encryption offered by DB2 SQL ? The Reference
manual has simple examples, look for ENCRYPT and DECRYPT
It's almost certainly not going to be stored in a database file, as
there is no practical reason to waste 36k to store (maybe) 32 bytes.
(It's ridiculous enough to waste 8k on storing them in a *DTAARA!) So
how would SQL encryption even apply?
The SQL is a language which provides support for parameters, result sets, and embedding in another language. The SQL will gladly set a value from a SQL statement in a variety of ways using those features, as a variable in a program irrespective the existence of any user-created database file. The following code snippet shows a string in variable StrOrig being encrypted into the variable StrEncrypt and then decrypted into the variable StrDecrypt. And although having no validation of SQLstate on any request and including the visible password, should be sufficient to show that no database file is required to invoke the cryptographic capabilities using just the SQL [and its scalars as the API] to get the string encrypted then decrypted. The SQL product need not be installed on any system on which the compiled program runs.
However there ¿may be requirements? for what level of Cryptographic capabilities are installed per: "_Administration of encrypted data:_ Encrypted data can only be decrypted on servers that support the decryption functions that correspond to the ENCRYPT_RC2 function." from the notes in the documentation for that SQL scalar.
<code>
h dftactgrp(*no)
D StrOrig S 24A Varying
D StrDecrypt S 24A Varying
D StrEncrypt S SQLTYPE(VARBINARY:48)
D Pwd S 127A Varying
C/free
Exec SQL
Set Option Commit=*NONE, DatFmt=*ISO
;
StrOrig='My *secret* value';
Pwd= 'My password';
Exec SQL
VALUES encrypt(:StrOrig, :Pwd) INTO :StrEncrypt
;
Exec SQL
VALUES decrypt_char(:StrEncrypt, :Pwd) INTO :StrDecrypt
;
DSPLY StrDecrypt ;
*inlr = *on;
</code>
Regards, Chuck
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at
http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.