Re: Random letters

2003-03-08 Thread ebgb
Hi all.

On Sat, Mar 08, 2003 at 08:03:11AM +0200, Octavian Rasnita wrote:
 I know how to create a random number, but could you tell me how can I create
 a random string that have numbers and letters?

I did it like this:

my $stuff = '';
for(1..100) { $stuff .= chr(int rand(96)+32); }

when I was playing with some code that needed to generate a browser id
to store in a cookie.  I stored just a hash of the above (and some
other stuff) in the cookie. 

There's probably better ways but that worked for me.  Hope it helps you.



Garrick.
-- 
It is easier to denature plutonium than to denature the evil spirit of man.
Albert Einstein (1879-1955)

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Needing a script to... [ make .doc files ]

2001-07-20 Thread ebgb

Hello Susan and cgi group.


On Tue, Jul 17, 2001 at 10:57:35AM -0700, Susan wrote:

 Does anyone know of a cgi or perl script that will work for taking the information 
from an online form, inputting the data onto a form on a word doc and then having 
that word doc form emailed to the email address?  I know this can be done though I 
can not quite work myself through this one. Thanks for any info...


I am working on something to do this as my company insists on having documentation
submitted in .doc format. I would much prefer to use .html and so should you if
at all possible.  In particular they make me submit Service-Requests in .doc which
is _very_ annoying as it means firing up StarOffice just to inform them that there
is _yet_ another IIS problem that needs fixing. :)  At the moment I have a script
that can generate the appropriate .doc by prompting for the text for each field
and fill in the template doc.  I do not have a web-inteface on it yet but I'm
working on that.  I couldn't use any of the OLE modules as I only use Gnu/Linux
by choice :)  Enough chat, time for how it works;  Nothing clever really.  I just
used StarOffice once to place markers in each field, such as abababababa
and then use s/// to replace the markers with the content you want.  You have
to be careful to maintain the same number of characters but you can pad with
spaces.  This isn't ideal as it doesn't allow you to edit a document other than
the prepared template but I might try and do something with storeing the offsets
and trying to combine that with some regex to be able to make a good guess at
where the data is.  I think it would be very difficult to change fonts or put
in more data than the template allowed unless you knew how .doc files work.

If there is any interest I will post the code to the group when I have a web-
interface otherwise I'd be flamed for not using CGI.pm :)  


On a related note;  Has any one made the OLE modules work under Gnu/Linux?  Would
it be possible to do something with WINE?  It would be very handy for work to be
able to get inside windows apps and files from my preferred environment.  Alternativly
has anyone tried anything like having a script running under NT with the OLE hooks
and communicating with a script under Un*x over a network connection?

Apologies for the long post.  I'm rambleing.

Regards all.

EbGb.
--
404 Not Found.
The requested sig://humourous.quote was not found on this server.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Crypt function

2001-06-27 Thread ebgb

On Wed, Jun 27, 2001 at 08:49:55AM -0700, James Kelty wrote:
 Can anyone point out a good book that details the functionality of perl
 and crypt()? I would like to have a cgi page that allows new member to
 sign up, hold the info in  a flat file, but I would like to have the
 passwords encrypted. Any help would be much appreciated! Thanks alot!


I normally use Digest::MD5 for this kind of thing.  The module, like most
others, is available from CPAN.

#!/usr/bin/perl -w

use Digest::MD5 qw(md5_hex);
use strict;

my $secret_password=foobarqux;
my $digest=md5_hex($secret_password);

This is not really encryption as it's a one-way function.  You can't reverse
the procedure to find the password from the digest so to authorise your users
you will need to perform the digest function on the password they've supplied
and compare it with the stored string.

Be wary of passing passwords over http as they can be sniffed, https would be 
preferred.

There's probably better ways of authenticating users.  I would be glad to learn
them from any of the real programmers on the list. :)

Regards.

EbGb.