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



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

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.