Click here to Skip to main content
15,893,486 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am new in ruby. I will give here one example in .NET. The same encryption data I need in ruby.

.Net Code-:
 using (SHA1 sha = new SHA1CryptoServiceProvider())
           {
               byte[] computeHash = sha.ComputeHash(enc.GetBytes(plainText + "." +
ConfigKey));

}

First it will convert the string to byte array and then computehash will change to Sha1 array.It will give the result in an integer array.

The same result I need in ruby, because I have some custom logic to implement after this result.



Thanks

What I have tried:

What I tried for this in ruby .

def hash1()
    computeencode  = []

    strhash = @plaintext.to_s() + "." + @configkey.to_s()
    computeencode = strhash.bytes

end

This bytes are same as I receive through .NET.
Then I tried to get Sha1 data.
sha1=(Digest::SHA1.hexdigest(computeencode.to_s))


But this result is not matching as Sha1 result in .Net.
Posted
Updated 9-Jun-19 22:48pm
v2

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900