Hey guys this is Master Jake and this tutorial was a request from—I can’t remember, I think Chris. But anyway, this tutorial is going to be over encryption. I'm assuming this is what he was talking about in the message. He said database encryption so you know I'm just going to go with this. Today we’re going to be learning about the md5 encryption which is—well it’s actually kind of a hash because you can’t really decrypt it. And then I'm also going to be talking about Base 64 which you actually can decrypt and you can use that for various things. I’ll show you some of the things I've used for it.
But anyway, go ahead and open up notepad and start PHP tags. This tutorial is going to be very simple. We’re just going to create a variable called mystring. And we’ll set the value of Hello World, then we’re going to echo out mystring. Go ahead and save this on the—let’s save it as enc.php, got to drag it into XAMPP projects, I got to start up Apache because I don’t have it on right now. And then let’s see, local host, oh yes I got to put it back in online mode, okay, load. My computer is so slow. Okay, sometimes I forget my password. Thankfully today isn’t one of those days.
All right, now I completely forgot where—enc.php—there it is, okay. So we’re going to go up here, you see it says Hello World on the screen. I got to pull that. All right, well that’s nothing special. You already know how to do that of course. To encrypt it, this one is very easy. md5 has its own function and—or hash it, whatever you want to call it. Go back into the file, all you need to do is put the md5, the function is called md5 and it takes a string. So md5, put the string right here, in this case Hello World, pretty simple. To function and you know, there is the md5 hash version of Hello World. Now it will always be the same but certain hashes have the same symbols which makes it very difficult.—can take a really long time with md5 so it’s the most secured probably.
So, now for—to put this in a database, you would just run a query screen, throw it in there. I don’t know if—I’ll go ahead and—well I'm now—you know how to insert stuff, you would just—it’s pretty obvious. You take the value of my string and insert it into the database. We’re worrying about that in the insert two tutorial from SQL and you just get in there and then you’d have an encrypted version in your database. This come in handy for username and password system, registration and login, you know, because you want to make sure the passwords are safe. Now, to actually decode it, you need to use something that’s decodable which would be base 64. The functions for that is base 64 encode to encode it, base 64 encode once again takes string. Let’s go ahead and that is Hello World in base 64 and then we’ll take right below that and we’ll echo out, well actually we’re going to echo out the value of my string and below that, we’re going to echo out the value of base 64 decode and then pass my string in once again. So this is going to echo out my string which is currently been set to encode it in base 64 of Hello World, and right below that, it’s going to decode it in the echo, while it’s echoing out, it’s going to decode it from base 64 and you will just see regular Hello World. There it is right there, I forgot to put a line break. Let’s go ahead and do that.
All right so there you go, regular Hello World, it has been decoded. Things you can use that for is when you're using php’s get imposed, you can add it to the end of the URL and make it, you know encode it in base 64. I mean, don’t use it for anything, really secure because I mean it can be decoded but if you're just trying to trick someone, like make them go to a URL they don’t want to, then here’s a little—and I’ll put the link in the video description of the place you can actually go to check this out on the Forefront Productions server, I have this system on there and basically it shows a normal URL, then on the end it has queue and it has a base 64 encrypted URL and what it does is, when the person visits the page, it takes whatever it takes, whatever is up here in the queue and base 64 decodes it to create the normal URL that’s not hidden, then it uses the php header to redirect them to the actual URL.
So basically what I'm getting at is if you want to trick someone to go to a different site, send them to this site, it will look real, something like that and then maybe this right here is actually youtube.com, maybe it’s the encrypted version of youtube.com, so it will come here and we’ll decrypt it, then it will relocate them to YouTube, and I will give you the link in the video description, so go check that out. And if you have—if you guys want to learn how to create that exact system, then just send me a private message because I'm running out of ideas for making videos and I still have a couple more weeks of full videos that I have to make. But I will show you this real quick, to redirect someone, use the header function and it takes a string, now the first part of the string needs to be location, colon, then you put the place to go. So in this case we could say youtube.com, header, location youtube.com, that’s how you redirect them. Now headers must be passed at the top of the file before html starts, generally, or it will give you an error and say headers have already been passed. But, yeah that’s how you do it, thanks for watching the video guys and I’ll see you the next time.
Transcription by:
Scribe4you Transcription Services