How to Verify File Integrity with Checksum using PowerShell

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so you've just downloaded that file from the internet but how do you know if it's safe how do you know that something hasn't been added to it that you don't want check sums are your answer they're going to keep you safe stay tuned to find out how so when you're downloading things from the internet it's important to make sure that you are keeping your computer and your data safe and that you know what you're downloading and it hasn't been modified either accidentally or maliciously and that's where checksums come into play now remember if you like this video make sure you click on subscribe so you don't miss out on any of our upcoming videos so you might have noticed when you download files from the internet many times they give you something known as the checksum or the hash value or the sha value or md5 those are the checksums those are what are going to allow you to verify that that file is indeed what you intend to download let me show you how it works so here i'm on video lan organization's webpage and they've got their vlc media player and if you click download vlc right in little teeny tiny print here you'll see where it says display checksum all right and what they want you to do is download the file and then click here and it's going to display this number this is the actual checksum what this is is the mathematical the answer to a mathematical equation we're going to take this file run it through a hashing algorithm generate this value and then they're going to display that value and what's really cool about hash algorithms is when you run that file through the algorithm it always generates the exact same output no matter how many times you run it through it's always going to generate the same exact output unless something changes if something in that file changes and you run it through the algorithm again the value is going to be completely different so this is how i can determine whether or not something has been modified or not if i download the file and i generate my own checksum and i compare it to the checksum that they've posted on the website if those two values are the same then i know nothing has been added to that file nothing has been modified if those two values don't match something is wrong with that file something has been added to it maybe maliciously that i don't want and i'm going to try to find another source for that file and it's all over the place right this was video lan organization if i go over to oracle box for example oracle they've got their virtual box i've got many different downloads i can do here if i scroll down i will find a little link that says hey you might want to compare the sha-256 or the md5 checksums to verify the integrity they're recommending that you need to make sure that this file hasn't been modified now they give you two different options there what those are are hashing algorithms i said there's a mathematical formula that we run the file through to generate this value well there's many different mathematical formulas i can use we just have to agree on one if the website is using sha-256 then when i run my own check i want to use sha-256 and compare those values compare apples to apples if the website is using md5 and i'm using sha-256 our values aren't going to match that's not going to give me accurate results so whatever they're using on the website is the one that you want to use as well and they'll typically tell you hey here's the sha-256 hash value or checksum for this file make sure you check it so how do we check it well once you've downloaded the file right we would click on a link like this and there are the values and they're telling you here's all the different files that we have here's all the checksums for those files now i've already taken the liberty of downloading one of their files and so on a windows machine our command is going to be get dash file hash right git dash file hash is the command that we can use to generate those hash values now this particular command has a couple parameters it needs to know what is it you're trying to run through the algorithm and what algorithm do you want to use right so the file i just downloaded is over and i'm going to call this is the path right so dash path e colon backslash downloads backslash virtual box so the path to the file that i want to check the sum of all right space dash algorithm and then the value for the algorithm that i want to use now they give me a choice i could either use sha-256 or md5 my pick i'm going to choose sha 256 all right now when i hit enter that's going to generate the hash value this is the result of that mathematical calculation now i need to compare it to what they gave me on the website so back over their file this is the one i downloaded right here box for windows so i'm going to grab this hash value checksum you can use those terms interchangeably right and i'm going to paste it right there and now i need to compare those two and make sure they're the same and you can kind of see the first one starts with ed5796 the one i just pasted in there ed5796 and we could keep going character by character comparing these i typically look at the first few characters and the last few characters and if those are the same i feel pretty safe because normally when there's a change the value changes to where you can easily see it's no longer the same it's not going to be just one little character change typically all right so usually you can just do a quick visual check and say okay those look the same i'm probably good now that's not the best way to do it right technically we should look at every single character and make sure they are the same and doing that with my old eyes can be challenging that's a lot of characters there and that's a short algorithm sha 512 is twice as long twice as many characters so doing those character comparisons can be a little tedious for it to do manually there are third-party applications that you can use where you can grab the hash value from the the website paste it into a box run the little program tell it what you're trying to check and it kind of does the comparison for you one of the cool things about this being a powershell command is that you can write your own program you could write a little script to do the comparison for you and i've done that so let's take a look at how that works all right here's my script most of this script is the form itself making it pretty the buttons things like that really the the meat of the the script and let me zoom in so you can read this here is right here we're going to get the file hash for whatever file it is that you're the one you just downloaded right so run that command that i just did manually ask the user to paste in a hash value of their own right the one you got from the website and then do the comparison if they equal each other you can see right here if one equals does not equal the other say they don't match if they do then say they match now this is not a programming class right we're not trying to learn how to script in five minutes but i just wanna this file will be available for you you can take it apart dissect it learn from it if you want let's see how it works so i named this script compare dash hash i think so i'm going to run compare dash hash and for my little script i need to tell it um what algorithm i need to paste in the value i'm sorry that i downloaded from the website so dash hash is going to be that value that i copied from the website i hit enter i find the file that i want to compare this to this is the one i downloaded i click open pick my algorithm click ok and there we go it does the comparison for me if they match i get a message like this the hash values match if they didn't match it would tell me in red hey the hash values don't match so just a little way that you can automate the checking of that that checksum comparing it to the value on that's been posted on the website so this is how you can use checksum to make sure that the files you're downloading from the internet are safe and have not been modified either maliciously or accidentally
Info
Channel: ITPro
Views: 16,968
Rating: undefined out of 5
Keywords: verify file, verify file integrity, verify files windows 10, verify file safety, file verification checksum, verify file integrity with checksum, checksum tutorial, checksum tutorial windows 10, checksum tutorial powershell, verify files with checksum, check file integrity, check file integrity windows 10, check file integrity powershell, checksum file integrity check, verify file integrity using checksum, checksum check in windows, file integrity monitoring best practices
Id: O0s8tKTL_MA
Channel Id: undefined
Length: 8min 21sec (501 seconds)
Published: Sun May 30 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.