[C#] SHA1 & MD5 Hashing

by IcyJake - 11-16-2017 - 05:03 AM
Posts:
206

Reputation:
19

Credits:

GoldDiamondKnightCredit WhoreTwitterGift
ι code ѕтυғғ
Diamond
Posts:
206

Threads:
29

Joined:
May 2017

Likes:
11

Credits:

Reputation:
19

Warning Level:

1 Year Of Service
GoldDiamondKnightCredit WhoreTwitterGift
#1
OP
Posted: 11-16-2017 - 05:03 AM
I got bored the other day and I don't visit this forum that much and I'm gonna try to change that, so to start that off, I'm going to share my class with you guys.

Code:
public class Hash
    {
        public string SHA1(string input)
        {
            byte[] hash;
            using (var sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider())
            {
                hash = sha1.ComputeHash(Encoding.Unicode.GetBytes(input));
            }
            var sb = new StringBuilder();
            foreach (byte b in hash) sb.AppendFormat("{0:x2}", b);
            return sb.ToString();
        }
        public string MD5(string input)
        {
            MD5 md5 = new MD5CryptoServiceProvider();
            string pass = Console.ReadLine();
            byte[] checkSum = md5.ComputeHash(Encoding.Unicode.GetBytes(input));
            string result = BitConverter.ToString(checkSum).Replace("-", String.Empty);
            return result.ToLower();
        }
    }

If you guys encounter any problems, just apprise me about it and I will try to implement some kind of fix to any problems. Enjoy. Cool
Posts:
15

Reputation:
0

Credits:

Rookie User
Posts:
15

Threads:
2

Joined:
Nov 2017

Likes:
2

Credits:

Reputation:
0

Warning Level:

1 Year Of Service
#2
Posted: 11-16-2017 - 12:42 PM
code looks good danke
Posts:
206

Reputation:
19

Credits:

GoldDiamondKnightCredit WhoreTwitterGift
ι code ѕтυғғ
Diamond
Posts:
206

Threads:
29

Joined:
May 2017

Likes:
11

Credits:

Reputation:
19

Warning Level:

1 Year Of Service
GoldDiamondKnightCredit WhoreTwitterGift
#3
OP
Posted: 01-23-2018 - 04:58 PM
adz8cika1 Wrote:code looks good danke

Thanks a lot man!!
Posts:
13

Reputation:
0

Credits:

Rookie User
Posts:
13

Threads:
3

Joined:
Jun 2017

Likes:
2

Credits:

Reputation:
0

Warning Level:

1 Year Of Service
#4
Posted: 03-08-2018 - 07:52 PM
Code is a bit messy but thanks for the share :)

:pepe:
Posts:
206

Reputation:
19

Credits:

GoldDiamondKnightCredit WhoreTwitterGift
ι code ѕтυғғ
Diamond
Posts:
206

Threads:
29

Joined:
May 2017

Likes:
11

Credits:

Reputation:
19

Warning Level:

1 Year Of Service
GoldDiamondKnightCredit WhoreTwitterGift
#5
OP
Posted: 03-11-2018 - 06:41 PM
(03-08-2018 - 07:52 PM)FTPService Wrote: Code is a bit messy but thanks for the share :)

How is it messy? Also, you're welcome.
Posts:
16

Reputation:
5

Credits:

Rookie User
Posts:
16

Threads:
3

Joined:
Jan 2016

Likes:
0

Credits:

Reputation:
5

Warning Level:

2 Years Of Service
#6
Posted: 03-22-2018 - 09:56 PM
(03-11-2018 - 06:41 PM)IcyJake Wrote:
(03-08-2018 - 07:52 PM)FTPService Wrote: Code is a bit messy but thanks for the share :)

How is it messy? Also, you're welcome.

Well they both use 2 entirely different methods to get the hex string for starters. And the 2nd method doesn't dispose of the MD5 provider.
Posts:
2

Reputation:
0

Credits:

Rookie User
Posts:
2

Threads:
1

Joined:
Mar 2018

Likes:
0

Credits:

Reputation:
0

Warning Level:

1 Year Of Service
#7
Posted: 03-22-2018 - 10:18 PM
You should use "var" always you can, like when you did "string pass" or "string result". Not big deal but it improve your code
Posts:
17

Reputation:
0

Credits:

Rookie User
Posts:
17

Threads:
0

Joined:
Dec 2018

Likes:
0

Credits:

Reputation:
0

Warning Level:

#8
Posted: 12-22-2018 - 04:46 AM
looks great dude keep up the work




USERS BROWSING THIS THREAD:  1 Guest(s)
"Join for the content, stay for the community."
© All Rights Reserved DemonForums.
© 2015-2019 / DemonForums
Server time: 03-20-2019, 01:35 PM (1242 Days Online)