A
A
Artyom Zubkov2011-02-15 05:51:29
Perl
Artyom Zubkov, 2011-02-15 05:51:29

Shell, replacing all characters in a string with their codes?

Hey!
Tell me, who knows how to replace all the characters of a string with their codes or some kind of hash, using shell commands.
Here is an example:

At the input
> hello world
And at the output, something like
> h2dfde3r443332d

Tried under windows via perl
$ perl -e 'print crypt("hello world", "a3")'

But issued:
The crypt() function is unimplemented due to excessive paranoia. at -e line 1.

Everything works fine on Linux.
So I'm looking for, so that under windows it would be possible with minimal cost, simply by installing msysGit, you could complete this task.
upd: I had to install ActivePerl.
earned.
but I will wait for the solution of the problem by means of sh.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vlad Frolov, 2011-02-15
@artzub

If a hash is needed:
$ echo "hello world" | md5sum
6f5902ac237024bdd0c176cb93063dc4 -

3
31z4, 2011-02-15
@31z4

str="hello world"; for ((i = 0; i < ${#str}; i++)); do printf '%x' "'$(expr substr "$str" $i 1)'"; done
Replaces all characters in a string with their codes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question