Dbms_crypto pacage

i tried to call dbms_crypto package from forms, i call the package by a function in the database i have created,
i always got the error 00904 , all the rights are given on the function and the crypto package
i use database 11 g and forms 10 g
i tried the function and the package logging with the same user in the database and it worked correctly,
so any settings i must do in the forms to call the crypto package correctly?

function for encryption
CREATE OR REPLACE FUNCTION ENC_FUN (P_PASS VARCHAR2)
RETURN RAW
IS
enc_val varchar2(2000);
l_key varchar2(2000) ;
l_master_key varchar2(2000) ;
l_in_val varchar2(2000) := P_PASS;
l_mod number ;
l_enc raw (2000);
l_enc_key raw (2000);
begin
l_mod := dbms_crypto.ENCRYPT_AES128
+ dbms_crypto.CHAIN_CBC
+ dbms_crypto.PAD_PKCS5;
SELECT PARAMETER_VALUE
INTO L_MASTER_KEY
FROM ADM_SYSTEM_PARAMETERS
WHERE PARAMETER_NAME='L_MASTER_KEY';
SELECT PARAMETER_VALUE
INTO L_KEY
FROM ADM_SYSTEM_PARAMETERS
WHERE PARAMETER_NAME='L_KEY';
l_enc_key := utl_raw.bit_xor (
UTL_I18N.STRING_TO_RAW (l_key, 'AR8MSWIN1256'),
UTL_I18N.STRING_TO_RAW (l_master_key, 'AR8MSWIN1256' ));
l_enc := dbms_crypto.encrypt
UTL_I18N.STRING_TO_RAW (l_in_val, 'AR8MSWIN1256'), l_mod, l_enc_key );
RETURN( rawtohex(l_enc));
EXCEPTION
WHEN OTHERS THEN NULL;
end;
function for decryption
CREATE OR REPLACE FUNCTION DEC_FUN (P_PASSWORD VARCHAR2) RETURN VARCHAR2
IS
l_key varchar2(2000) ;
l_master_key varchar2(2000);
l_in_val raw (2000) := hextoraw(P_PASSWORD);
l_mod number := dbms_crypto.ENCRYPT_AES128
+ dbms_crypto.CHAIN_CBC
+ dbms_crypto.PAD_PKCS5;
l_dec raw (2000);
l_enc_key raw (2000);
begin
SELECT PARAMETER_VALUE
INTO L_MASTER_KEY
FROM ADM_SYSTEM_PARAMETERS
WHERE PARAMETER_NAME='L_MASTER_KEY';
SELECT PARAMETER_VALUE
INTO L_KEY
FROM ADM_SYSTEM_PARAMETERS
WHERE PARAMETER_NAME='L_KEY';
l_enc_key := utl_raw.bit_xor (
UTL_I18N.STRING_TO_RAW (l_key, 'AR8MSWIN1256'),
UTL_I18N.STRING_TO_RAW (l_master_key, 'AR8MSWIN1256')
l_dec := dbms_crypto.decrypt
l_in_val,
l_mod,
l_enc_key
RETURN (utl_i18n.raw_to_char(l_dec));
end;
i call both of them in the form and it gives me the error 00904 using the following code
DECLARE
     V_PASS VARCHAR2(100);
begin
     V_PASS:=ENC_FUN(:USER_PASSWORD);
END;

Similar Messages

  • Error when useing DBMS_CRYPTO package in reports 10g

    hi all,
    i wrote a package which use dbms_crypto, there are functions to crypto userid and decrypo userid.
    in report 6i it work fine it cryptos and decrpts. when i use in reports 10g it gives this error.
    -28817 ORA-28817: PL/SQL function returned an error.
    ora-06512: at "SYS.DBMS_CRYPTO_FFI", line 67
    ORA-06512: at "SYS.DBMS_CRYPTO", line 41
    ora-06512: at "YBS.SIFRELE", line 26
    the packege like this;
    PACKAGE BODY SIFRELE
    IS
    function sicil_sifrele (p_sicil_no IN varchar2) RETURN varchar2
    IS
    p_key RAW(128);
    p_sicil_raw RAW(128);
    p_encrypted_raw RAW(128);
    BEGIN
    p_key := utl_raw.cast_to_raw(to_char(sysdate,'mmyyyydd'));
    p_sicil_raw := utl_raw.cast_to_raw(p_sicil_no);
    p_encrypted_raw := dbms_crypto.encrypt(src => p_sicil_raw,
    typ => dbms_crypto.des_cbc_pkcs5, key => p_key);
    return (utl_raw.cast_to_varchar2(p_encrypted_raw));
    END;
    FUNCTION sicil_coz ( p_encrypted_raw IN RAW) RETURN varchar2
    IS
    p_key RAW(128);
    p_decrypted_raw RAW(128);
    sicil_donen VARCHAR2(250);
    BEGIN
    p_key := utl_raw.cast_to_raw(to_char(sysdate,'mmyyyydd'));
    p_decrypted_raw := dbms_crypto.decrypt(src => p_encrypted_raw,
    typ => dbms_crypto.des_cbc_pkcs5, key => p_key);
    sicil_donen := utl_raw.cast_to_varchar2(p_decrypted_raw);
    return (sicil_donen);
    END;
    END;
    thanks.
    eser

    Hello,
    You should create a "wrapper function"
    Create a function in the database that will call dbms_crypto.encrypt / dbms_crypto.decrypt and call this function in Reports.
    (The problem here seems to be the reference to dbms_crypto.des_cbc_pkcs5)
    Regards

  • Using DBMS_CRYPTO package in reports

    hi all,
    i want to encrypt & decrypt user parameter in report.
    to encrypt i use;
    l_encrypted_raw := dbms_crypto.encrypt(src => my_parameter,
    typ => dbms_crypto.des_cbc_pkcs5, key => l_key);
    to decrypt;
    l_decrypted_raw := dbms_crypto.decrypt(src => l_encrypted_raw,
    typ => dbms_crypto.des_cbc_pkcs5, key => l_key);
    in sql developer these codes are running. i can encrypt & decrypt
    but when i want to decrypt in reports it gives an error like this:
    implementation restriction: 'DBMS_CRYPTO.DES_CBC_PKCS5': Cannot directly access remote package variable or cursor
    how can i pass this?
    thanks...

    Hello,
    You should create a "wrapper function"
    Create a function in the database that will call dbms_crypto.encrypt / dbms_crypto.decrypt and call this function in Reports.
    (The problem here seems to be the reference to dbms_crypto.des_cbc_pkcs5)
    Regards

  • Error when using DBMS_CRYPTO package in reports 10g

    hi all,
    i wrote a package which use dbms_crypto, there are functions to crypto userid and decrypo userid.
    the packege like this;
    PACKAGE BODY SIFRELE
    IS
    function sicil_sifrele (p_sicil_no IN varchar2) RETURN varchar2
    IS
    p_key RAW(128);
    p_sicil_raw RAW(128);
    p_encrypted_raw RAW(128);
    BEGIN
    p_key := utl_raw.cast_to_raw(to_char(sysdate,'mmyyyydd'));
    p_sicil_raw := utl_raw.cast_to_raw(p_sicil_no);
    p_encrypted_raw := dbms_crypto.encrypt(src => p_sicil_raw,
    typ => dbms_crypto.des_cbc_pkcs5, key => p_key);
    return (utl_raw.cast_to_varchar2(p_encrypted_raw));
    END;
    FUNCTION sicil_coz ( p_encrypted_raw IN RAW) RETURN varchar2
    IS
    p_key RAW(128);
    p_decrypted_raw RAW(128);
    sicil_donen VARCHAR2(250);
    BEGIN
    p_key := utl_raw.cast_to_raw(to_char(sysdate,'mmyyyydd'));
    p_decrypted_raw := dbms_crypto.decrypt(src => p_encrypted_raw,
    typ => dbms_crypto.des_cbc_pkcs5, key => p_key);
    sicil_donen := utl_raw.cast_to_varchar2(p_decrypted_raw);
    return (sicil_donen);
    END;
    END;
    in report 6i it work fine cryptos and decrpts. when i use in reports 10g it gives this error.
    -28817 ORA-28817: PL/SQL function returned an error.
    ora-06512: at "SYS.DBMS_CRYPTO_FFI", line 67
    ORA-06512: at "SYS.DBMS_CRYPTO", line 41
    ora-06512: at "YBS.SIFRELE", line 26
    thanks...

    Hello,
    You should create a "wrapper function"
    Create a function in the database that will call dbms_crypto.encrypt / dbms_crypto.decrypt and call this function in Reports.
    (The problem here seems to be the reference to dbms_crypto.des_cbc_pkcs5)
    Regards

  • DBMS_CRYPTO package help needed :(

    Hello all,
    I want to use Oracle's DBMS_CRYPTO package for decrypting some data.
    I have one sample program as follows which is not working....the error is shown below.
    SQL> DECLARE
    2 input_string VARCHAR2 (200) := 'Secret Message';
    3 output_string VARCHAR2 (200);
    4 encrypted_raw RAW (2000); -- stores encrypted binary text
    5 decrypted_raw RAW (2000); -- stores decrypted binary text
    6 num_key_bytes NUMBER := 256/8; -- key length 256 bits (32 bytes)
    7 key_bytes_raw RAW (32); -- stores 256-bit encryption key
    8 encryption_type PLS_INTEGER := -- total encryption type
    9 DBMS_CRYPTO.ENCRYPT_AES256
    10 + DBMS_CRYPTO.CHAIN_CBC
    11 + DBMS_CRYPTO.PAD_PKCS5;
    12 BEGIN
    13 DBMS_OUTPUT.PUT_LINE ( 'Original string: ' || input_string);
    14 key_bytes_raw := DBMS_CRYPTO.RANDOMBYTES (num_key_bytes);
    15 encrypted_raw := DBMS_CRYPTO.ENCRYPT
    16 (
    17 src => UTL_I18N.STRING_TO_RAW (input_string, 'AL32UTF8'),
    18 typ => encryption_type,
    19 KEY => key_bytes_raw
    20 );
    21 decrypted_raw := DBMS_CRYPTO.DECRYPT
    22 (
    23 src => encrypted_raw,
    24 typ => encryption_type,
    25 KEY => key_bytes_raw
    26 );
    27 output_string := UTL_I18N.RAW_TO_CHAR (decrypted_raw, 'AL32UTF8');
    28 DBMS_OUTPUT.PUT_LINE ('Decrypted string: ' || output_string);
    29 END;
    30 /
    DBMS_CRYPTO.ENCRYPT_AES256
    ERROR at line 9:
    ORA-06550: line 9, column 2:
    PLS-00201: identifier 'DBMS_CRYPTO' must be declared
    ORA-06550: line 8, column 23:
    PL/SQL: Item ignored
    ORA-06550: line 14, column 21:
    PLS-00201: identifier 'DBMS_CRYPTO' must be declared
    ORA-06550: line 14, column 4:
    PL/SQL: Statement ignored
    ORA-06550: line 15, column 21:
    PLS-00201: identifier 'DBMS_CRYPTO' must be declared
    ORA-06550: line 15, column 4:
    PL/SQL: Statement ignored
    ORA-06550: line 21, column 18:
    PLS-00201: identifier 'DBMS_CRYPTO' must be declared
    ORA-06550: line 21, column 1:
    PL/SQL: Statement ignored
    Oracle version is
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production on linux server.
    can anybody help me how to resolve this problem?
    I mean isnt "DBMS_CRYPTO" Oracle's Standard package?
    pls help.

    Really you should not be using SYSTEM account - you should create your own DBA / Development accounts and use those.
    However, what you are missing is to connect as SYS/SYSDBA and...
    GRANT EXECUTE ON dbms_crypto TO system;

  • Dbms_crypto package for number and date data type

    Hi,
    I am using Oracle 10g 10.2.0.3 on Linux 64 bit
    I am tryiing to use dbms_crypto package for the first time to encypt my tables column
    Following are my table columns
    NAME1 VARCHAR2(2000),
    ID1 NUMBER,
    SCORE number
    This table is already populated
    i want to encrypt Name1 and Score column. Following are the functions i have created for Encryption and decryption.
    --For Encryption
    create or replace function get_enc_val
    p_in in varchar2,
    p_key in raw
    return raw is
    l_enc_val raw (2000);
    l_mod number := dbms_crypto.ENCRYPT_AES128
    + dbms_crypto.CHAIN_CBC
    + dbms_crypto.PAD_PKCS5;
    begin
    l_enc_val := dbms_crypto.encrypt
    UTL_I18N.STRING_TO_RAW
    (p_in, 'AL32UTF8'),
    l_mod,
    p_key
    return l_enc_val;
    end;
    --For Decryption
    create or replace function get_dec_val
    p_in in raw,
    p_key in raw
    return varchar2
    is
    l_ret varchar2 (2000);
    l_dec_val raw (2000);
    l_mod number := dbms_crypto.ENCRYPT_AES128
    + dbms_crypto.CHAIN_CBC
    + dbms_crypto.PAD_PKCS5;
    begin
    l_dec_val := dbms_crypto.decrypt
    p_in,
    l_mod,
    p_key
    l_ret:= UTL_I18N.RAW_TO_CHAR
    (l_dec_val, 'AL32UTF8');
    return l_ret;
    end;
    Key: I have stored a key in other schema and calling it by using function get_key().
    Following is my insert
    INSERT INTO Score_table VALUES
    (get_enc_val('John',get_key()),25,get_enc_val(79,get_key()))
    it is giving me following error
    ORA-00932:Inconsistent Datatypes:Expected number got binary.
    I checked, it is an error due to Score field, which is of number type. So do i need to change type of Score field to varchar or is there any other way to encrypt number and date field.
    If i need to change the type then what will happen to the data already in Table and how do i encrypt data already in table.

    Hi,
    Is there any one who can tell me that, do i need to change my table column data type as the encrypted value will be character.

  • How could I Encrypt the data of SDO_GEOMETRY type using DBMS_CRYPTO package

    Hi:
    I want to Encrypt the data of SDO_GEOMETRY object type using DBMS_CRYPTO package.
    What could I do? hope anyone can help me,give me a suggestions!
    thanks in advance.
    lgs

    well, the spatial api would not be able to handle this data anymore, so what you are trying to do is converting an SDO_GEOMETRY to some cryptable user type (see http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_crypto.htm#sthref1506) and encrypting this.
    Before using the SDO_GEOMETRY type will have to decrypt and reconvert it again and pass it to the spatial query or function.

  • How to find length of string after encryption using DBMS_CRYPTO package

    Hi,
    I am planning do data encryption using DBMS_CRYPTO package. I want to find how much will be string length after encryption.
    e.g When I try to encrypt string of length between 1-15 characters it gives me encrypted string of 32 characters. When I try with 16 charcters encrypted string is of 64 characters.
    Is ther any formula to calculate length of encrypted string?
    Thanks
    Pravin

    The length change is dependent upon the algorithm you are using which can be a combination of cipher block, padding, and chaining.
    The best solution is determine the method you are going to use and apply it to the l ongest possible strings you are going to proces, then add some safety margin. There iis no penalty for defining your column as VARCHAR2(4000).

  • Can't find DBMS_CRYPTO package in my 10g R1

    Hi, I want to use the DBMS_CRYPTO pakage, I found some plsql code to use it, but when compile my code, the databse told me that this pakage not exists, I try with SYS user, but alwas the same error. I can't find this package that assumes to be included in 10g.
    Thanks

    What is the output of this query?
    SQL> select object_name, owner, object_type from dba_objects where object_name = 'DBMS_CRYPTO' ;
    OBJECT_NAME                    OWNER                          OBJECT_TYPE
    DBMS_CRYPTO                    SYS                            PACKAGE
    DBMS_CRYPTO                    SYS                            PACKAGE BODY
    DBMS_CRYPTO                    PUBLIC                         SYNONYM
    SQL> disconnect
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL>

  • Dbms_crypto - avoid error when using different key in lower environment

    Hello Experts,
    We are using Oracle 11.2.0.2. We are planning to implement dbms_crypto to encrypt few columns. We clone the data from production to lower environment ( DEV, QC).
    For the lower environments, we do not want to get the sensitive data from production and do not plan to use same key. Rather than getting an error when using differnt key, is it possible to get a different resultset back.
    In other words, we want the implementation to be same across environments but want to use a diffent key in lower environment and get different result (or garbage).
    Any suggestions would be greatly appreciated.
    While testing this logic, I am getting following error when using differnt key to decrypt. It works fine if I use same key.
    Error at line 1
    ORA-28817: PL/SQL function returned an error.
    ORA-06512: at "SYS.DBMS_CRYPTO_FFI", line 67
    ORA-06512: at "SYS.DBMS_CRYPTO", line 44
    ORA-06512: at line 19
    DECLARE
      l_credit_card_no    VARCHAR2(19) := '1234 5678 9012 3456';
      l_ccn_raw           RAW(128) := UTL_RAW.cast_to_raw(l_credit_card_no);
    l_key               RAW(128) := UTL_RAW.cast_to_raw('abcdefgh');
       l2_key               RAW(128) := UTL_RAW.cast_to_raw('12345678');
      l_encrypted_raw     RAW(2048);
      l_decrypted_raw     RAW(2048);
    BEGIN
      DBMS_OUTPUT.put_line('Original  : ' || l_credit_card_no);
      l_encrypted_raw := DBMS_CRYPTO.encrypt(src => l_ccn_raw,
                                             typ => DBMS_CRYPTO.des_cbc_pkcs5,
                                             key => l_key);
      DBMS_OUTPUT.put_line('Encrypted : ' || RAWTOHEX(UTL_RAW.cast_to_raw(l_encrypted_raw)));
      l_decrypted_raw := DBMS_CRYPTO.decrypt(src => l_encrypted_raw,
                                             typ => DBMS_CRYPTO.des_cbc_pkcs5,
                                             key => l2_key); --**Using different key to decrypt
      DBMS_OUTPUT.put_line('Decrypted : ' || UTL_RAW.cast_to_varchar2(l_decrypted_raw));
    END;Thank you.

    If I understand what you are trying to do ... and I may not ... it is not going to work.
    SQL> DECLARE
      2   l_credit_card_no VARCHAR2(19) := '1612-1791-1809-2605';
      3   l_ccn_raw RAW(128) := utl_raw.cast_to_raw(l_credit_card_no);
      4   l_key1     RAW(128) := utl_raw.cast_to_raw('abcdefgh');
      5   l_key2     RAW(128) := utl_raw.cast_to_raw('zyxwvuts');  -- alternate key used to attempt a different decryption
      6 
      7   l_encrypted_raw RAW(2048);
      8   l_decrypted_raw RAW(2048);
      9  BEGIN
    10    dbms_output.put_line('Original : ' || l_credit_card_no);
    11 
    12    l_encrypted_raw := dbms_crypto.encrypt(l_ccn_raw, dbms_crypto.des_cbc_pkcs5, l_key1);
    13 
    14    dbms_output.put_line('Encrypted : ' || RAWTOHEX(utl_raw.cast_to_raw(l_encrypted_raw)));
    15 
    16    l_decrypted_raw := dbms_crypto.decrypt(src => l_encrypted_raw, typ => dbms_crypto.des_cbc_pkc
    s5, key => l_key1);
    17 
    18    dbms_output.put_line('Key1 : ' || utl_raw.cast_to_varchar2(l_decrypted_raw));
    19 
    20    l_decrypted_raw := dbms_crypto.decrypt(src => l_encrypted_raw, typ => dbms_crypto.des_cbc_pkc
    s5, key => l_key2);
    21 
    22    dbms_output.put_line('Key2 : ' || utl_raw.cast_to_varchar2(l_decrypted_raw));
    23  END;
    24  /
    Original : 1612-1791-1809-2605
    Encrypted : 3534443342333642353141363846384237463732384636373943374630364234323243334539383042323135
    Key1 : 1612-1791-1809-2605
    DECLARE
    ERROR at line 1:
    ORA-28817: PL/SQL function returned an error.
    ORA-06512: at "SYS.DBMS_CRYPTO_FFI", line 67
    ORA-06512: at "SYS.DBMS_CRYPTO", line 44
    ORA-06512: at line 20

  • Need some hints on using dbms_crypto

    Hello,
    I need some hints on using the dbms_crypto package to generate some password for the OID userpassword attribute. The passwordstring is stored in a format {CRYPT}dasdasdawdww, {SHA}jfsklefjskldjkdlkldf, {MD4}dfdsfgsdgdfewwe or {MD5}fsdfsdadsgdfg where the keyword in the curly brackets describes the encryption methods. I think CRYPT means DES, SHA means SHA-1.
    The key for the DES encryption for UNIX password authentification is in the first 2 letters of the encrypted string. I wanna have an encryption function which encrypts the clear type passwords in the right format like this perl script:
    #!/bin/perl
    print crypt($ARGV[0],"HS");
    #: crypt.pl Test123 # program fetch
    HSF0Sx2zdrLoQ
    Regards
    Holger

    Hello,
    meanwhile I made some investigations on the Problem
    I tried this code:
    DECLARE
    input_string       VARCHAR2 (200) :=  'Test123';
    output_string      VARCHAR2 (200);
    encrypted_raw      RAW (2000);             -- stores encrypted binary text
    decrypted_raw      RAW (2000);             -- stores decrypted binary text
    num_key_bytes      NUMBER := 256/8;        -- key length 256 bits (32 bytes)
    key_bytes_raw      RAW (32);               -- stores 256-bit encryption key
    encryption_type    PLS_INTEGER :=          -- total encryption type
                             DBMS_CRYPTO.ENCRYPT_DES
                           + DBMS_CRYPTO.CHAIN_CBC
                           + DBMS_CRYPTO.PAD_PKCS5;
    BEGIN
            DBMS_OUTPUT.PUT_LINE ( 'Original string: ' || input_string);
            key_bytes_raw := UTL_I18N.STRING_TO_RAW ( 'HS' );
            encrypted_raw := DBMS_CRYPTO.ENCRYPT
                            src => UTL_I18N.STRING_TO_RAW (input_string,  'AL32UTF8'
                            typ => encryption_type,
                            key => key_bytes_raw
    -- The encrypted value "encrypted_raw" can be used here
            DBMS_OUTPUT.PUT_LINE ( 'Encrypted string: ' || encrypted_raw);
            decrypted_raw := DBMS_CRYPTO.DECRYPT
                            src => encrypted_raw,
                            typ => encryption_type,
                            key => key_bytes_raw
            DBMS_OUTPUT.PUT_LINE ('Decrypted string: ' || UTL_I18N.RAW_TO_CHAR (decr
    ypted_raw, 'AL32UTF8'));
            DBMS_OUTPUT.PUT_LINE ('Encrypted Char string: ' || UTL_I18N.RAW_TO_CHAR
    (encrypted_raw, 'AL32UTF8'));
    END;
    /and got these error messages:
    ERROR at line 1:
    ORA-28234: key length too short
    ORA-06512: at "SYS.DBMS_CRYPTO_FFI", line 3
    ORA-06512: at "SYS.DBMS_CRYPTO", line 10
    ORA-06512: at line 15In the next try:
    DECLARE
    input_string       VARCHAR2 (200) :=  'Test123';
    output_string      VARCHAR2 (200);
    encrypted_raw      RAW (2000);             -- stores encrypted binary text
    decrypted_raw      RAW (2000);             -- stores decrypted binary text
    num_key_bytes      NUMBER := 256/8;        -- key length 256 bits (32 bytes)
    key_bytes_raw      RAW (32);               -- stores 256-bit encryption key
    encryption_type    PLS_INTEGER :=          -- total encryption type
                             DBMS_CRYPTO.ENCRYPT_DES
                           + DBMS_CRYPTO.CHAIN_CBC
                           + DBMS_CRYPTO.PAD_PKCS5;
    BEGIN
            DBMS_OUTPUT.PUT_LINE ( 'Original string: ' || input_string);
            key_bytes_raw := UTL_I18N.STRING_TO_RAW ( 'HS12345678901234' );
            encrypted_raw := DBMS_CRYPTO.ENCRYPT
                            src => UTL_I18N.STRING_TO_RAW (input_string,  'AL32UTF8'
                            typ => encryption_type,
                            key => key_bytes_raw
    -- The encrypted value "encrypted_raw" can be used here
            DBMS_OUTPUT.PUT_LINE ( 'Encrypted string: ' || encrypted_raw);
            decrypted_raw := DBMS_CRYPTO.DECRYPT
                            src => encrypted_raw,
                            typ => encryption_type,
                            key => key_bytes_raw
            DBMS_OUTPUT.PUT_LINE ('Decrypted string: ' || UTL_I18N.RAW_TO_CHAR (decr
    ypted_raw, 'AL32UTF8'));
            DBMS_OUTPUT.PUT_LINE ('Encrypted Char string: ' || UTL_I18N.RAW_TO_CHAR
    (encrypted_raw, 'AL32UTF8'));
    END;
    /I got some results which have nothing in common with the perl script:
    Original string: Test123
    Encrypted string: DE5668CD7762074C
    Decrypted string: Test123
    Encrypted Char string: ?h?bL
    PL/SQL procedure successfully completed.Come to think of it I doubt if DBMS_CRYPTO is the right way to solve my problem. Any further hints?
    Regards Holger

  • Encrypt and decrypt using dbms_crypto.hash

    hi to all i am newbie here and i've just want to ask if how can i decrypt the encryted password.
    v_pass_string = 'qwerty';
    lower(dbms_crypto.hash(to_clob(v_pass_string),3))
    The out is: b1b3773a05c0ed0176787a4f1574ff0075f7521e
    and i want to output it into original data which is *'qwerty'*
    please help...
    thanks in advance

    You can't.
    HASH is not an encryption algorithm, it is a one-way hashing algorithm. HASHed cannot be converted back to the original value. This is one reason they are used for passwords as they offer the best security.
    If you want to encrypt and decrypt values you would use the ENCRYPT and DECRYPT functions of the DBMS_CRYPTO package...
    http://www.psoug.org/reference/dbms_crypto.html

  • Grant execute on DBMS_CRYPTO package (11R1)

    I figured out I needed to grant my user access to this SYS package using:
    SQL> grant execute on DBMS_CRYPTO to lob_demo;
    Grant succeeded.
    yet after doing this, I still get this error:
    SQL> select DBMS_CRYPTO.HASH(bytes, DBMS_CRYPTO.HASH_SH1) from blobslicer where id=1;
    select DBMS_CRYPTO.HASH(bytes, DBMS_CRYPTO.HASH_SH1) from blobslicer where id=1
    ERROR at line 1:
    ORA-06553: PLS-221: 'HASH_SH1' is not a procedure or is undefined
    Yet if I use the numeric constant for DBMS_CRYPTO.HASH_SH1 (3), it works:
    SQL> select DBMS_CRYPTO.HASH(bytes, 3) from blobslicer where id=1;
    F5A7338EFFEB15A49AFC9545393EF685BB51F931
    So what am I missing that prevents me from having access to a constant in the package when I can successfully use one of the function of that same package?
    Thanks, --DD                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Maybe, that makes a little bit clearer the difference
    between usage of package constants in sql and pl sql...That's what I suspected, thank you for hammering the point home Maxim.
    The taken away for me is that package constants are not available to SQL code, only to PL/SQL code. (irrelevant of their type most likely).
    I actually tried to grant my user SELECT privileges on the package, because accessing a constant from a package is more akin to SELECT than EXECUTE, but of course one cannot do that.
    Thank you both again for the help. --DD                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Key generation using DBMS_CRYPTO

    Hi,
    I have a question about DBMS_CRYPTO pacakge , which can be used for encrypting sensitive data. When we use this package, is it a must that we have to supply the encryption key or is it that the package can itself generate the key? I read in the documentiation about RANDOMBYTES function (http://download.oracle.com/docs/cd/B14117_01/appdev.101/b10802/d_crypto.htm#1000530) but I don't know exactly how it can be used.
    Basically my doubt is, when we use this package, we have to pass in the encryption key as a parameter and we have to know it or is there a way oracle can entirely take care of it?
    Thanks

    The way the DBMS_CRYPTO package works is with providing an encryption key to encrypt and to decrypt. I think personal looking at your question and the remarks you place you are looking for a solution like "Oracle Advanced Security", see http://www.oracle.com/us/products/database/options/advanced-security/index.html
    Regards, Gerwin

  • Can the dbms_crypto package be used to decrypt a winzip file?

    I have a password protected winzip file. I know the password.
    Is it possible to decrypt this file using dbms_crypto or is this not supported?
    I have searched everywhere for the answer!
    Please help :-)
    Thanks

    simple example...
    create or replace and compile java source named unZip as
    import java.io.ByteArrayOutputStream;
    import java.util.zip.Inflater;
    public class ByteArrayUnzip {
    public byte[] decompressByteArray(byte[] bytes){
            ByteArrayOutputStream baos = null;
            Inflater inf = new Inflater();
            inf.setInput(bytes);
            baos = new ByteArrayOutputStream();
            byte[] temp = new byte[4*1024];
            try {
                 while(!inf.finished())
                    int size = inf.inflate(temp);
                    baos.write(temp, 0, size);
            } catch (Exception e){
            } finally {
                try{
                    if(baos != null) baos.close();
                } catch(Exception e){}
            return baos.toByteArray();
    create or replace function unzip (p_buf in raw) return raw
    as language java
    name 'ByteArrayUnzip.decompressByteArray(byte[]) return byte[]';
    declare
    v_buf raw(2000);
    v_res raw(2000); -- or blob maybe
    begin
    v_buf := <your data>
    v_res := unzip(v_buf);
    end;
    hope it'll help

Maybe you are looking for

  • Linking report column to open a webpage

    Hi All, Need a sincere help. I have a table TAB_ARC. In which i have columns ID PART_NUM LINK_TO_PART_NUM (Its a hyperlink) I have made report and form on same. I am inserting PART_NUM and LINK_TO_PART_NUM (which is a web link respective to the PART_

  • My iPad Mini was locked up today (for the first time) on a boot screen, with a Debugger Message: Panic. Should I bother trying to fix, or return to store?

    My iPad Mini locked up for the first time today. A boot screen, with among many other things, a Debugger Message: Panic. Is there a fix for this even though I can't seem to even get it to reboot past this error, or am I wasting my time and need to re

  • Screensaver pulling images from who knows where...

    All, I'm a bit confused here. My screen saver used to be an album in my iPhoto. However, seemingly out of nowhere, it was pulling images from who knows where and all over the place. I have deleted my iPhoto library and re-imported my images and re-ma

  • TABLE in a class

    I am new to ABAP, however I'd prefer to use ABAP objects if possible. Do I understand that a class cannot contain the TABLES keyword!!!  If so what strategy do I use such that a class or instanciated object may own it's own data. In other words the c

  • Printer changes number of copies

    hp officejet J4680 - printer wants to change the number of copies I request - I only want one and it changes that instruction to 6 or 8 or 7 - whatever it feels like - anyone had this problem?