I have a file with encrypted credentials with RC4, The piece of code in charge to write such credentials to the file is the following:
sub dummyFunction() {
# Useless stuff for the scope of the problem
# ...
my $dbHost = "localhost";
my $passphrase = "123"; # For example purposes, logic is different.
my $cipher = Crypt::RC4->new($passphrase);
return unpack('H*',$cipher->RC4($dbHost));
}
So that piece of code would return something like: 3F9FDCE3891C6B8851
but if I try the following:
sub anotherDummyFunction() {
my $ciphered_text = &dummyFunction();
my $passphrase = "123";
my $cipher = Crypt::RC4->new($passphrase);
print $cipher->RC4(pack('H*',$ciphered_text));
}
I am expecting to see localhost
but instead, I get a bunch of bytes, so how would I get back the original text?
I already checked with a RC4 decryptor online, with my passphrase and my hex encoded string and the RC4 decryptor online does return localhost
so I am sure that the encrypted string is right.
Thanks!
P.S.: The above example works in an isolated environment, but when it comes to my script it doesn't. I cannot get back the original string.