Jump to content

C# Checksum Checker

Torand

Hey guys,

 

Just thought I'd share a project I've been working on for a few hours.

 

After downloading the Windows 10 dev preview, I checked the SHA1 hash using FCIV, A small MS CLI based application that allows you to check the checksum of files passed into it.

 

I don't mind CLI, but one thing that did bug me about FCIV is that you couldn't pass it a checksum to check against and it just return True of False.

 

Project excuse time!

 

Delving into C# with my first* project! This should be good. One practice I've always adhered to is that there is no point just using something, learn how to do it/use it, otherwise what is the point? You won't know how to implement it in future or know when to implement it, take the extra few minutes and just read into it, learn. siderant: it's why I try to avoid YouTube tutorials that just gloss over why and just tell you to write x. Not helpful!

 

So, practicing what I preach, this project will always be heavily commented and nothing will be just used without learning from it. Just to allow people - including my future self - to easily see what is doing what and, moderately, why. Also, the commenting does reinforce whats going in for me, in terms of learning, so there's that. I can certainly say that in the short time in which I've been creating this project, I've learnt a significant amount and found myself just writing out entire code blocks in my own memory buffer before the hardware fingers can catch up.

 

So here it is, Checksum Checker V1 (.0.0.0), have a play and see what you think. I have a todo list already and have plans to sustain the project in my spare time, for now.

 

You can view the here: Shiny GitHub Project

 

(*I've touched on C# before, just to have a look and worked in other OOP languages.)

 

Please forgive any formatting or spelling errors, it's late, I'm a night owl kinda person and get intense coding energy at around midnight. Why now dammit!

Link to comment
Share on other sites

Link to post
Share on other sites

programmers gonna check check check check

:D

will check on this later.

 

 

i'm wondering though any reason for going into c#?

 

also makes me wonder that maybe microsoft is gonna release a better version of it w/ Windows 10 be it in CLI or GUI

|CPU: Intel i7-5960X @ 4.4ghz|MoBo: Asus Rampage V|RAM: 64GB Corsair Dominator Platinum|GPU:2-way SLI Gigabyte G1 Gaming GTX 980's|SSD:512GB Samsung 850 pro|HDD: 2TB WD Black|PSU: Corsair AX1200i|COOLING: NZXT Kraken x61|SOUNDCARD: Creative SBX ZxR|  ^_^  Planned Bedroom Build: Red Phantom [quadro is stuck in customs, still trying to find a cheaper way to buy a highend xeon]

Link to comment
Share on other sites

Link to post
Share on other sites

programmers gonna check check check check

:D

will check on this later.

 

 

i'm wondering though any reason for going into c#?

 

also makes me wonder that maybe microsoft is gonna release a better version of it w/ Windows 10 be it in CLI or GUI

 

Can't really think of my reasoning for C# other than I have VS 2012 and wanted to use it for something, so I cracked open and started a C# project. (we don't talk about vb)

 

Maybe they are, who knows. I've certainly seen a lot more companies embrace the file hashing system for checking if its a complete/legitimate download, so we might see it become more prevelant - who knows.

 

Have a look any way and see what you think! :P (it's not efficient in the slightest, but threading was a plus point, even if it is just workers)

Link to comment
Share on other sites

Link to post
Share on other sites

Only thing I didn't like about the code was all the redundant return statements and initializing values for some fields.

Unreachable break statement at line 525

 

Nothing wrong with your use of case statements =) Could use enums if you wanted the case statements to be more readable

Link to comment
Share on other sites

Link to post
Share on other sites

Could use some refactoring. Wouldn't hurt to add testing too.

 

void methods don't need return statements so you should remove them.

 

It's convention to add the access modifier (public, private, etc) to your classes fields. And you don't need to initialize fields to their default values.

public class Example{    private int number; // contains 0 by default    private bool flag; // contains false by default    // etc}
Link to comment
Share on other sites

Link to post
Share on other sites

Only thing I didn't like about the code was all the redundant return statements and initializing values for some fields.

Unreachable break statement at line 525

 

Nothing wrong with your use of case statements =) Could use enums if you wanted the case statements to be more readable

 

Cool, thanks. Still in the initial learning phase of the language, with my only relatable experience being in native C. Returning functions was just second nature, haha. As for initialising variables, yeh, it was more for my reference on what I was using. The un-reachable break statement I already knew about when I was writing it, it was just again for code OCD :P

 

Yeh the switch works, but it just isn't pretty, that's all. I'll look into enums - they look slightly complicated? :o

 

 

 

Could use some refactoring. Wouldn't hurt to add testing too.

 

void methods don't need return statements so you should remove them.

 

It's convention to add the access modifier (public, private, etc) to your classes fields. And you don't need to initialize fields to their default values.

public class Example{    private int number; // contains 0 by default    private bool flag; // contains false by default    // etc}

 

Yeh, it was top of my todo list haha. What form of testing? Recommendations / sources to research?

 

Yep, the returns - many returns.

 

Shit, I actually completely forgot about the access modifier. I'm actually really confused as to how I forgot that - something in which I do subliminally in other languages... kind of embarassing! :P

 

Got the thing with default value init~. I presume my reset function is OK though? :)

Link to comment
Share on other sites

Link to post
Share on other sites

Yeh, it was top of my todo list haha. What form of testing? Recommendations / sources to research?

 

Unit and integration testing is probably all you need right now.

 

A great book for unit testing is The Art Of Unit Testing 2nd Edition but you can look into finding other resources if you don't want to buy something.

 

 

I presume my reset function is OK though? :)

 

Yes, that looks fine and would be necessary to reset modified values.

 

Also, just wanted to clarify, return statements in void functions are fine if you want to exit early on an execution path (can be necessary for error handling, input validation, etc). It's just having them at the end of an execution path isn't needed.

Link to comment
Share on other sites

Link to post
Share on other sites

Unit and integration testing is probably all you need right now.

 

A great book for unit testing is The Art Of Unit Testing 2nd Edition but you can look into finding other resources if you don't want to buy something.

 

 

 

Yes, that looks fine and would be necessary to reset modified values.

 

Also, just wanted to clarify, return statements in void functions are fine if you want to exit early on an execution path (can be necessary for error handling, input validation, etc). It's just having them at the end of an execution path isn't needed.

 

Thanks, I shall certainly read into it! :)

 

Good. As for the returns, yeh - i knew that, it was just for the end of the function that I was unsure of. Thank you, anyway! :)

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×