[Vb] [C#] Sha1 hashing
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
9 posts
Page 1 of 1
Hello,
I haven't seen any tutorials on this on Codenstuff well couldn't find any anyway. I was posting a tutorial on this because I thought it would be good to show how you can has text that can't be decrypted.
Unfortunately don't know much about cryptography and Sha1 CAN'T be decrypted but it can easily be brute forced.
Overview of Sha1
Sha stands for secure hash algorithm and sha1 is basically the version (sha0-sha3) and was published 1993. It is the most common hash function.
If you want to learn more about it just look it up.
Other interesting types of encryption include Symmetric encryption which is where we use an IV and a key which we use to Encrypt and Decrypt text and Asymmetric encryption is where We have a different Key and IV to encrypt and decrypt but it is recommended to use GenerateKey() and generateIV() each session.
With this tutorial we have a function called Sha1has and we call that with the text we want encrypted. We declare a new instance of the Sha1CryptoServiceProvider. We declare a byte and we set that to our string we're converting then we use our sha1 to compute the byte hash. Then we run a loop for every byte we find in our byte hash and we hash it :P then we output the encrypted text.
Visual Basic Code:
To call out function I have two textboxes one is for the text to be encrypted and one is for the output. The output is named txtOutput and the text to be encrypted is named txtEncrypt.
We create a button called btnEncrypt and on the click event of the button we call the function and in brackets we give it the text we're encrypting. After we've clicked the button our hashed text will appear in the output.
Sha1Hash(txtEncrypt.Text)
I've zipped up the project if you want to download the code.
![Image]()
I hope I've helped, thanks.
I haven't seen any tutorials on this on Codenstuff well couldn't find any anyway. I was posting a tutorial on this because I thought it would be good to show how you can has text that can't be decrypted.
Unfortunately don't know much about cryptography and Sha1 CAN'T be decrypted but it can easily be brute forced.
Overview of Sha1
Sha stands for secure hash algorithm and sha1 is basically the version (sha0-sha3) and was published 1993. It is the most common hash function.
If you want to learn more about it just look it up.
Other interesting types of encryption include Symmetric encryption which is where we use an IV and a key which we use to Encrypt and Decrypt text and Asymmetric encryption is where We have a different Key and IV to encrypt and decrypt but it is recommended to use GenerateKey() and generateIV() each session.
With this tutorial we have a function called Sha1has and we call that with the text we want encrypted. We declare a new instance of the Sha1CryptoServiceProvider. We declare a byte and we set that to our string we're converting then we use our sha1 to compute the byte hash. Then we run a loop for every byte we find in our byte hash and we hash it :P then we output the encrypted text.
Visual Basic Code:
Code: Select all
Send the text to be encrypted: Function Sha1hash(ByVal StringToEncrypt As String) As String
Dim Sha1 As New Security.Cryptography.SHA1CryptoServiceProvider
Dim b_ToHash() As Byte = System.Text.Encoding.ASCII.GetBytes(StringToEncrypt)
b_ToHash = Sha1.ComputeHash(b_ToHash)
Dim HashedString As String = ""
For Each b As Byte In b_ToHash
HashedString += b.ToString("x2")
Next
txtOutput.Text = HashedString
Return Nothing
End Function
Code: Select all
C# Code: Private Sub btnEncrypt_Click(sender As System.Object, e As System.EventArgs) Handles btnEncrypt.Click
Sha1hash(txtEncrypt.Text)
End Sub
Code: Select all
public string Sha1hash(string StringToEncrypt)
{
System.Security.Cryptography.SHA1CryptoServiceProvider Sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider();
byte[] b_ToHash = System.Text.Encoding.ASCII.GetBytes(StringToEncrypt);
b_ToHash = Sha1.ComputeHash(b_ToHash);
string HashedString = "";
foreach (byte b in b_ToHash) {
HashedString += b.ToString("x2");
}
txtOutput.Text = HashedString;
return null;
}
Code: Select all
Above is the function we use (which I described). Sorry i didn't describe it very well it's a confusing subject. private void btnEncrypt_Click(System.Object sender, System.EventArgs e)
{
Sha1hash(txtEncrypt.Text);
}
To call out function I have two textboxes one is for the text to be encrypted and one is for the output. The output is named txtOutput and the text to be encrypted is named txtEncrypt.
We create a button called btnEncrypt and on the click event of the button we call the function and in brackets we give it the text we're encrypting. After we've clicked the button our hashed text will appear in the output.
Sha1Hash(txtEncrypt.Text)
I've zipped up the project if you want to download the code.

I hope I've helped, thanks.
You do not have the required permissions to view the files attached to this post.
Last edited by smashapps on Sat Dec 05, 2015 11:21 am, edited 2 times in total.
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
sha (secure hash algorithms but its not secure anymore lol)

- SHA-0
SHA-1
SHA-2
SHA-256
SHA-384
SHA-512
- HAVAL
RIPEMD-320
Gost 64
Whirlpool

Find my programs on Softpedia
I haven't heard of those algorithms before. I'll edit the post when I can to better explain a couple things too.
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
benji_19994 wrote:Shim sha1 can be brute forced not decrypted -__-http://www.sha1.cz/
http://www.md5decrypter.co.uk/sha1-decrypt.aspx
http://www.stringfunction.com/sha1-decrypter.html
if the hash is already been cracked you could decrypt or something something
Find my programs on Softpedia
Isn't that funny i tried all of them with the hash sha1 ben and none of them online scanners guessed it
benji_19994 wrote:Isn't that funny i tried all of them with the hash sha1 ben and none of them online scanners guessed itas i said before if the hash was cracked by dictionary attack etc someone will add the decrypted text to the website so one when we go give a decrypt try if the hash matches the hash in the database it will show the decrypted text ............................................................
Find my programs on Softpedia
Well anyway as a programmer i try and make my programs secure so they cannot even get the hashed passwords
Okay thanks for clarifying that I still thought it was a good tutorial to show people how to hash passwords.
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
9 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023