Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASCII values in perl????

Status
Not open for further replies.

Oxymoron

Technical User
Dec 17, 2000
168
GB
hey every1.
i want to make an encrypted password file. So is there anyway of getting the ASCII values of characters entered so i can substitute the letter for the value??

if any1 can help id b very grateful! cheers every1!!
JoE we are all of us living in the gutter.
But some of us are looking at the stars.
 
unless you just want to do this yourself there are a lot of encryption modules already. And theres always the crypt function but i'm not sure it works under windows.
 
The ord function returns the ASCII value of a
character.
 
im not overly bothered about encryption that the NSA use :p
id just like to make a simple script that uses the ASCII values of characters.
is there any way of getting the ASCII value of a character in perl?????????????????

any info would be great!
Thanks!
JoE we are all of us living in the gutter.
But some of us are looking at the stars.
 
$string = "this is just a test. jt.,ai;323f;,+";
$filename = "path/to/output.txt";

@encrypted_string = unpack("U*", $string);
# now you can write this to a file
print @encrypted_string;

# to enencrypt, read file into array, then:
$unencrypted_string = pack("C*", @encrypted_string);

print $unencrypted_string;


# note that unpack() takes a string and gives a list.
# pack() takes a list and gives a string.

--jim

 
By the way, when you write that encrypted array to a file, make sure you set

$\="\n"; # before the print statement

or

print FILE_HANDLE_HERE "$_\n" for @encrypted_string;

This way it's not just a string of numbers when you read it back in, and it retains it's list-property.

--jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top