Re: Column Encryption
Posted in 1995
Michael L. Gonzales <76543.2600@CompuServe.COM> writes: >I need a method to take entered data (passwords), encrypt the >value, and store the value in a column. Obviously, I would need >to decipher the stored value for future validations. The purpose >of this is to merely keep any individual from scanning the >database for passwords. >Any recommendations on encrypting data? Following is my password encryption algorithm. Caveat emptor. ___ ___ Senior Consultant / ) __ . __/ /_ ) _ _ __ Informix Software Inc. (303) 850-0210 _/__/ (_(_ (/ / (_(_ _/__) (-' ~/ '(_- 5299 DTC Blvd #740 Englewood CO 80111 dberg@informix.com Opinions expressed herein are my own. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #---------------------------------------------------------------------- FUNCTION encrypt (l_password) # ARGUMENTS: CHAR(8) or less to which to apply password en-/de-cryption # PURPOSE: Encrypt or decrypt a user password # RETURNS: En- or De-crypted value (NULL indicates invalid value passed in.) #---------------------------------------------------------------------- DEFINE l_password CHAR(8) DEFINE l_encrypt CHAR(8) DEFINE l_char_set CHAR(62) DEFINE l_encrypt_set CHAR(62) DEFINE i, j, k SMALLINT LET l_char_set = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" LET l_encrypt_set = "NoPqRsTuVwXyZAbCdEfGhIjKlMnOpQrStUvWxYzaBcDeFgHiJkLm5678901234" INITIALIZE l_encrypt TO NULL IF LENGTH(l_password) > 0 THEN LET j = 1 LET k = LENGTH(l_password) FOR i = 1 TO LENGTH(l_password) FOR j = 1 TO LENGTH(l_char_set) IF l_password[i,i] = l_char_set[j,j] THEN LET l_encrypt[k,k] = l_encrypt_set[j,j] LET k = k - 1 EXIT FOR END IF END FOR IF j > LENGTH(l_char_set) THEN LET l_encrypt = NULL EXIT FOR END IF END FOR END IF RETURN l_encrypt END FUNCTION # encrypt