Home » RDBMS Server » Security » A random password generator
A random password generator [message #4955] Wed, 22 January 2003 08:27 Go to next message
xander
Messages: 9
Registered: December 2001
Junior Member
Does anyone have an example of a procedure that creates
a random password for a user in pl/sql. I'm just looking for some ideas. perhaps the user name and a random 4 digit number or combining user name and todays date and then I would just encrypt. I'm not worrying about encrupt yet ...just the password generator. Thanks
Re: A random password generator [message #4963 is a reply to message #4955] Wed, 22 January 2003 11:10 Go to previous messageGo to next message
xander
Messages: 9
Registered: December 2001
Junior Member
anyone...????
Re: A random password generator [message #4965 is a reply to message #4955] Wed, 22 January 2003 11:26 Go to previous messageGo to next message
Art Metzer
Messages: 2480
Registered: December 2002
Senior Member
SQL> CREATE OR REPLACE FUNCTION generate_string_1
  2  RETURN VARCHAR2
  3  IS
  4      l_string        VARCHAR2(35);
  5  BEGIN
  6      SELECT vs.username
  7      ||     TO_CHAR(MOD(ABS(DBMS_RANDOM.RANDOM),10000),'fm0000')
  8      INTO   l_string
  9      FROM   v$session   vs
 10      WHERE  vs.audsid = USERENV('SESSIONID');
 11      
 12      RETURN (l_string);
 13  END generate_string_1;
 14  /
  
Function created.
  
SQL> CREATE OR REPLACE FUNCTION generate_string_2
  2  RETURN VARCHAR2
  3  IS
  4      l_string        VARCHAR2(35);
  5  BEGIN
  6      SELECT vs.username
  7      ||     TO_CHAR(SYSDATE,'YYYYMMDD')
  8      INTO   l_string
  9      FROM   v$session   vs
 10      WHERE  vs.audsid = USERENV('SESSIONID');
 11      
 12      RETURN (l_string);
 13  END generate_string_2;
 14  /
  
Function created.
  
SQL> SELECT generate_string_1 FROM DUAL;
  
GENERATE_STRING_1
-------------------------------------------------------
AMETZER<b>2264</b>
  
SQL> SELECT generate_string_1 FROM DUAL;
  
GENERATE_STRING_1
-------------------------------------------------------
AMETZER<b>0878</b>
  
SQL> SELECT generate_string_2 FROM DUAL;
  
GENERATE_STRING_2
-------------------------------------------------------
AMETZER20030122
  
SQL> 
A
Re: A random password generator [message #4967 is a reply to message #4955] Wed, 22 January 2003 11:43 Go to previous messageGo to next message
xander
Messages: 9
Registered: December 2001
Junior Member
Hi art, thanks for the example...I need to do this in a procedure rather then a function...is it easy for me to make that transition?
Re: A random password generator [message #4969 is a reply to message #4967] Wed, 22 January 2003 12:37 Go to previous messageGo to next message
xander
Messages: 9
Registered: December 2001
Junior Member
okay.....YOU TRULY ROCK........followed your advice and got it going on first try. Thank YOU!
Encryption on password...help? [message #4971 is a reply to message #4967] Wed, 22 January 2003 13:13 Go to previous messageGo to next message
xander
Messages: 9
Registered: December 2001
Junior Member
It helped a bunch ...thanks again....
Now about encrupting...

what I did was

CREATE OR REPLACE Procedure pass_gen
(p_user in VARCHAR2,
o_pass out VARCHAR2)
is
BEGIN
select user_Id
|| TO_CHAR(SYSDATE,'YYYYMMDD')
into o_pass
from user_table
where user_Id = P_User
and Ref_co = not null
and edate is null;

END;
/

Now I want to encrypt the value in o_pass, the book im looking at is showing encrypting of source code which is not helpful. I am searching the net but encryting a password appears to be scarce code to fine (unless im searching it wrong)...

Can anyone offer help or insight?
Re: Encryption on password...help? [message #4972 is a reply to message #4967] Wed, 22 January 2003 13:25 Go to previous messageGo to next message
Art Metzer
Messages: 2480
Registered: December 2002
Senior Member
quote:
----------------------------------------------------------------------
Now I want to encrypt the value in o_pass, the book im looking at is showing encrypting of source code which is not helpful. I am searching the net but encryting a password appears to be scarce code to fine (unless im searching it wrong)...

Can anyone offer help or insight?

----------------------------------------------------------------------
See this discussion.

A
Re: A random password generator [message #8585 is a reply to message #4955] Tue, 02 September 2003 10:51 Go to previous message
a
Messages: 22
Registered: March 2002
Junior Member
Hi,

Do you still have that script for random passwd generator? I wish to use it.

regds,
A.
Previous Topic: insufficient priv's
Next Topic: how to read password ?
Goto Forum:
  


Current Time: Fri Mar 29 06:00:25 CDT 2024