1 2 Previous Next 18 Replies Latest reply: Feb 6, 2013 4:31 AM by Purvesh K Go to original post RSS
      • 16. Re: How to mask and unmask a creditcard number in oracle
        Purvesh K
        I this closes your questions pertaining to the thread, then please close it by marking as Answered. You may choose to mark a post as Correct/Helpful, as appropriate to you.
        • 17. Re: How to mask and unmask a creditcard number in oracle
          970843
          Hi purvesh, here in the example u posted, i cant find anything which decrypts the data
          • 18. Re: How to mask and unmask a creditcard number in oracle
            Purvesh K
            im_user1 wrote:
            Hi purvesh, here in the example u posted, i cant find anything which decrypts the data
            Let me show you, in case you have missed it.
            declare
                cursor c_cur is
                    select uname, password from encryption;
            begin
                delete encryption where 1 = 1;
                dbms_output.put_line('Starting Block...');
                insert into encryption values (1, 'purvesh', 'purvesh');        ----> Due to this Insert, password is not Encrypted and is visible as entered i.e. purvesh.
                    dbms_output.put_line('Before Encryption');    
                    for rec in c_cur loop
                    dbms_output.put_line('UName :: ' || rec.uname || '; Password :: ' || rec.password);
                    end loop;
                    dbms_output.put_line('');
            
            
                user_security.update_user_password ('purvesh', 'purv');     ----> I update the Password as purv instead of purvesh. This password is not Hash-ed using DBMS_OBFUSCATION_TOOLKIT.
            
                  /*
                     Display the Encrypted password
                  */
                    dbms_output.put_line('After Encryption');
                    for rec in c_cur loop
                    dbms_output.put_line('UName :: ' || rec.uname || '; Password :: ' || rec.password);
                    end loop;
                    dbms_output.put_line('');
            
                 /*
                    USER_SECURITY package (code is present in the Link mentioned earlier) has a Declared Function Decrypt
                    which accepts the Entrypted password and returns a Human readable password as it was entered. i.e. in my situation purv.
                */
            dbms_output.put_line('Decryption!!!');
                    for rec in c_cur loop
                        dbms_output.put_line('Original Password for purvesh is ' || user_security.decrypt(rec.password ));       
            end loop;
                commit;
                dbms_output.put_line('End Block...');
            end;
            Is the explanation satisfactory to clear your questions?

            In case you want to Encrypt the data at First instance of Insert, you can add some code to something like below:
            --Package Specification
            PROCEDURE insert_user_password (
                  p_username       IN   VARCHAR2,
                  p_password   IN   VARCHAR2);
            
            
            --Package Body
            PROCEDURE insert_user_password (
                  p_username       IN   VARCHAR2,
                  p_password   IN   VARCHAR2
               )
               AS
                  v_rowid   ROWID;
            
               BEGIN
            
                 insert into encryption values (uname_seq.next_val, p_username, encrypt(p_password));
             
               EXCEPTION
                  WHEN Others
                  THEN
                      RAISE;
               END;
            Edited by: Purvesh K on Feb 6, 2013 3:57 PM
            Added Insert_User_password procedure
            1 2 Previous Next