Forum: Ruby encryption using ruby

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
2d8b8b3782611eae032f194a900db4ef?d=identicon&s=25 Vetrivel Vaithilingam (vetrivel)
on 2009-02-21 04:58
Herewith I have given code of perl encryption and decryption . If i give
123 as
no,the perl , encrypted the data and give it to us.How to do this in
ruby.But If i give 123,the ruby should encrypt the data . The encrypted
data should be same what perl has given.

use Crypt;
print "enter the normal pin\n";
$entered_pin = <STDIN>;
chomp ( $entered_pin );
my $EPin = Crypt::Encrypt ( $entered_pin );
print "Encrypted pin is : $EPin\n\n\n";
print "enter the encrypted pin\n";
$entered_pin = <STDIN>;
chomp ( $entered_pin );

chomp ( $entered_pin );
for ($i=0; $i<=9999; $i++) {
    $pin = sprintf("%04d", $i);
    $ret = Crypt::Decrypt ($pin, $entered_pin);
    if ($ret == 0) {
        print "The Pin is $pin\n";
753dcb78b3a3651127665da4bed3c782?d=identicon&s=25 Brian Candler (candlerb)
on 2009-02-23 14:26
Please see my answer at where
exactly the same question was answered, but the OP didn't bother to

Here you have posted a bit more code. This shows that no decryption is
taking place at all; rather, the Perl is trying all possible PINs until
it stumbles on the correct one (AKA a "brute-force attack")

Anyway, you just need to look at either the documentation for the perl
Crypt::Encrypt function you are using to find out what sort of hashing
it is doing, or probably easier, look at the Perl source and
re-implement in Ruby.
This topic is locked and can not be replied to.