here basic code to check the strength of your application password if you want to restrict the user by choosing strong password here we just check for the Mixing Characters and the length of the password , you can also append the checking of upper case and lower case mix that is means that the user must enter password that containing mixing case of characters (at least one upper case letter and at least one lower case letter)
create or replace function check_password_stren(p_password varchar2) return number is
0 means the password doesn't meet any requirement
1 means only meet the minimum length
2 means exceed the minimum length
4 means meet the lenght and mixed character and numbers
5 exceed the length and mixed character and numbers
0 means the password doesn't meet any requirement
1 means only meet the minimum length
2 means exceed the minimum length
4 means meet the lenght and mixed character and numbers
5 exceed the length and mixed character and numbers
v_min_len number(2):=10 ; --- variable according to your bussiness requirements
v_count number(2);
v_len number(5);
v_mix_state number(5);
begin
v_count number(2);
v_len number(5);
v_mix_state number(5);
begin
v_len:=length(p_password);
if v_len < v_min_len then
v_count:=0;
return v_count;
elsif v_len=v_min_len then
v_count:=1;
else
v_count:=2;
end if ;
v_count:=0;
return v_count;
elsif v_len=v_min_len then
v_count:=1;
else
v_count:=2;
end if ;
v_mix_state:= nvl(length(translate(trim(p_password),'0123456789',' ')),0);
if v_mix_state =0 then ---- it is numbers only
v_count:=v_count+0;
elsif v_mix_state=v_len then -- it is characters only
v_count:=v_count+0;
elsif v_mix_state<>v_len then --- it is mix
v_count:=v_count+3;
end if ;
v_count:=v_count+0;
elsif v_mix_state=v_len then -- it is characters only
v_count:=v_count+0;
elsif v_mix_state<>v_len then --- it is mix
v_count:=v_count+3;
end if ;
return v_count ;
end;
end;