Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: DBMS_CRYPTO question
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
Received on Tue Jun 20 2006 - 13:02:30 CDT
![]() |
![]() |