Encryption in oracle

Hi Team,

Iam trying to encrypt the password from the user tables using the

Iam using cursor for loop to process each record in the table , hence iam passing the field as rec.password.

But is generating the same value for all the records in the user table.

Any help is really appreciated.

USers tables

userid   username password
1             sam            sam0001
2             michael      michael002
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SujithData ArchitectCommented:
You are passing a string "REC.PASSWORD" by enclosing it in single  quotes. Remove the single quote and

change it to -
slightwv (䄆 Netminder) Commented:
The values is generated when the cursor is executed not fetched.

You can simulate that with this simple test:
for i in (select sysdate from dba_objects where rownum<6) loop
end loop;

Open in new window

With the 1 second sleep, all the sysdate values return the same value.

You need to move the call to generate the passwords inside the loop.
SujithData ArchitectCommented:
@Sam you have named the package incorrectly in your code, see the below

SQL> select * from tbl1;

---------- -------------------- --------------------
         1 sam                  sam0001
         2 michael              michael002

SQL> begin
  2      for rec in (select password from tbl1) loop
  3          dbms_output.put_line(DBMS_OBFUSCATION_TOOLKIT.md5(input_STRING =>UTL_I18N.STRING_TO_RAW(REC.PASSWORD)));
  4      end loop;
  5  end;
  6  /

PL/SQL procedure successfully completed.

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.