Click here to Skip to main content
15,915,600 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Protected Function encrypt(ByVal pass As String) As String

       encrypt = Nothing
       Dim bytPassword As Byte() = Nothing
       Dim bytHash As Byte() = Nothing
       Dim sha1Obj As SHA384Managed = New SHA384Managed()
       bytPassword = Encoding.UTF8.GetBytes(pass)
       bytHash = sha1Obj.ComputeHash(bytPassword)

       sha1Obj.Clear()

       encrypt = System.Convert.ToBase64String(bytHash)
 End Function


What I have tried:

how to decrypt from encrypt code below
Posted
Updated 30-Aug-16 1:38am

SHA384 is not a cypher algorithm, it's a hash algorithm.
You cannot "decrypt" a hash value; thus, it is impossible to get the initial value back from its hashed value.

If you want to compare hashed passwords, you have to compute the hash of the provided password, and compare it to the stored hash-value.
 
Share this answer
 
v2
Comments
bejos3519 30-Aug-16 6:15am    
i have try like this :

Dim x As Byte() = Nothing
x = System.Convert.FromBase64String(encrypt)

but i dont know how to reverse from
bytHash = sha1Obj.ComputeHash(bytPassword)
phil.o 30-Aug-16 6:17am    
You cannot reverse a hashed value. You cannot retrieve the original value from the hashed one.
bejos3519 30-Aug-16 7:26am    
im so sad. :(
but nothing can do...

thank you friend.
The first answer was 100% - but I'll use this to explain to you what it means in simpler detail.

Encryption/Decryption: these are used to take data of some kind (like a message) and make it unreadable (encryption) until someone with the proper tool can convert it back to its original form (decryption). This usually takes a password of some kind so that simply having the same tool won't open the door.

Hash: Is a way to take data and, through a mathematical algorithm, convert it to a new value that should be unique to the original data. Unique in this case only means that if you (1) start with the same data, and (2) apply the same hash algorithm, (3) you'll get the same result. Basically, though, the data was sliced and diced and chopped and scrunched in ways that cannot be reversed. For example, if I use something like addition as my hash algorithm, and I give you the answer as 100, you don't know how I got it: 1+99, 3+72+25, etc., etc., This example is very crude. True hashes are very large results from much more complicated arithmetic so accidentally having the same value is all but impossible.

So - for encryption, you have a result that can be restored to its original state. For a Hash, you cannot undo it. What you can do, however is hash a known value and test to see if it matches your stored value (example, passwords).

 
Share this answer
 
Comments
bejos3519 30-Aug-16 7:28am    
oh tears... im so sad.
but thanks friend
W Balboos, GHB 30-Aug-16 7:31am    
And thank you - an opportunity to teach is an opportunity to learn. One thing to keep in mind with this Q&A area: if any of the answers "ANSWERS" you question, accept it and thus the question is marked answered and removed from the open question cue. Just good housekeeping.
Quote:
how to decrypt from encrypt code below
You don't!
Because SHA384 is bot encryption, it is not reversible.
SHA is like a checksum.
Example: get this value 12345678987654321011234596789
get the checksum t(his way: 12+34+56+78+98+76+54+32+10, you get 450 and you apply again to 4+50 and you 54 as a checksum.
what you want is to reverse the process, it is impossible.
SHA is just more complicated in the way that it is very hard to find 2 strings that will give the same result, and it is all the interest of SHA.
 
Share this answer
 
v2

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