Oracle Random Password Generator

create or replace function random_str(v_length number) return varchar2 is
   my_str varchar2(4000);
begin
   for i in 1..3 loop
       my_str := my_str || dbms_random.string(
           case when dbms_random.value(0, 1) < 0.5 then 'l' else 'x' end, 1);
   end loop;  

   my_str:=my_str||SUBSTR (REPLACE ('*_-#@+?!', 'X'),

              DBMS_RANDOM.VALUE (1, 8),

              1);

   for i in 3..v_length-1 loop
       my_str := my_str || dbms_random.string(
           case when dbms_random.value(0, 1) < 0.5 then 'l' else 'x' end, 1);
   end loop;
  
   return my_str;
end;

 

Add comment

Loading