Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: DBMS_CRYPTO question

Re: DBMS_CRYPTO question

From: <nkunkov_at_escholar.com>
Date: 20 Jun 2006 12:08:17 -0700
Message-ID: <1150830497.868211.40210@p79g2000cwp.googlegroups.com>

Vladimir M. Zakharychev wrote:
> nkunkov_at_escholar.com wrote:
> > Hello,
> > I'm using DBMS_CRYPTO.hash (SH1) and DBMS_CRYPTO.encrypt (AES256).
> > I'm hashing and encrypting VARCHAR2(12) and NUMBER(32) columns. I'm
> > wondering what is a max length of my hash for both datatypes and what
> > is a max length of my encrypted string for both datatypes. I'm
> > converting the output of each function (raw(2000))to varchar2. I need
> > to know the max size of that character string that would be returned.
> > Thank you for your help.
> > nk
>
> SHA-1 hashes are always 160 bits in size, which translate to 20 bytes.
> If you translate raw to a hexadecimal representation, the hash size
> will be 40 hex characters.
>
> AES-256 uses 256-bit keys, but block size is still 128 bit, which
> translates to 16 bytes, so your message is padded to the length
> of CEIL(LENGTHB(message)/16)*16 bytes and this will be the
> encrypted output size. Since you didn't specify if your VARCHAR2
> uses BYTE or CHAR length semantics, I can't say for sure that
> output size will always be 16 bytes. Again, if you convert that to
> hex then double the size.
>
> Hth,
> Vladimir M. Zakharychev
> N-Networks, makers of Dynamic PSP(tm)
> http://www.dynamicpsp.com

Vladimir,
Thank you very much.
I assume your answer goes for both Varchar2 as an input and NUMBER(32) as an input for encryption/hashing right? I use CHAR length semantics.  I made my output to be varchar2(200) to be safe, for both functions and for both input datatypes. I think this should be enough. Again, your help is greatly appreciated. NK Received on Tue Jun 20 2006 - 14:08:17 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US