Sciguyryan's Blog

Setting up a local web server with WAMP

by on Oct.02, 2011, under General, Personal, Tutorials

Hi everyone.

This is something I recently had to do so I figured I’d share this with anyone else out there that may want to know. For a long time I’ve wanted to setup a local web server to build and test sites locally without the need to continually upload the files (and as a plus of course, local files are easier to back up). After some research and playing this is the process I eventually came up with to get the optimal configuration for what I need.

Firstly it was a choice between XAMPP and WAMP. I ended up choosing WAMP because I didn’t need Perl. Other than that they seemed about equal.

After downloading the EXE I installed it (obviously) and copied the files to the www folder (which is located in C:\wamp\www\ by default). I noticed a few problems right away however. .htaccess rewrites didn’t work as the module was enabled. To re-enable it I clicked on the icon in the task bar, clicked on “Apache”, then “Apache modules” and selected “rewrite_module”. I then had to restart the server by clicking on the icon once again and selecting “restart all services”.

That fixed most of the rewrites not not all of them worked. It turned out this was because I needed to add a virtual host for the project. Luckily this also wasn’t difficult to achieve.

First you need to pick a name for the virtual host, I picked tnda because that was the name of my project. That name will be used in my examples here. After picking the name you must then open the following file: “C:\Windows\System32\drivers\etc\hosts” in your favorite text editor. At the bottom of the file you need to add a line like this, substituting tnda with your chosen project name. Note that this name CANNOT include spaces!

1
127.0.0.1       tnda

After doing that, save and close the file.

Next we need to modify the Apache virtual hosts file. This one is also luckily pretty simple. In the default WAMP install it should be located here:”C:\wamp\bin\apache\Apache2.2.21\conf\extra\httpd-vhosts.conf”. Of course the Apache version may vary depending on when you installed the program. Open this program in your favorite text editor and at the bottom of the file you need to add this. Substitute the path here “c:/wamp/www/tnda” with the path to the folder in which your project lies. You also need to replace the server name (TNDA here) with the name chosen in your hosts file above.

1
2
3
4
5
6
7
8
9
10
<VirtualHost *:80>
    DocumentRoot "c:/wamp/www/tnda"
    ServerName tdna
    <Directory />
        Options Indexes FollowSymLinks
        AllowOverride All
        Order Allow,Deny
        Allow from all
    </Directory>
</VirtualHost>

Save and close the file. Now you again need to restart Apache. You will now find that you can use full mod-rewrite rules on that project and as a plus you’ll be able to use http://projectname to access the resources quickly locally when the server is active.

I hope this helps people simplify the process.

Comments Off on Setting up a local web server with WAMP more...

File Shredder Code Sample (C# 4.0)

by on Jul.23, 2011, under Code Snippet

It has been a while since I last posted a code sample. So here is one for you guys to take a look at. Below is the file/directory shredder class.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
class FileUtilities
{
    private static Random Randomizer = new Random();

    public static bool Shred(string directoryPath, bool shouldDelete = true)
    {
        bool success = true;
        try
        {
            string[] files = Directory.GetFiles(directoryPath, "*", SearchOption.AllDirectories);
            foreach (string file in files)
            {
                success &= FileUtilities.ShredFile(file, shouldDelete);
            }

            string[] directories = Directory.GetDirectories(directoryPath,
                                                            "*",
                                                            SearchOption.AllDirectories).OrderByDescending(str =>
                                                                                                           str.Split('\\').Length - 1).ToArray();
            foreach (string directory in directories)
            {
                success &= FileUtilities.ShredDirectory(directory, shouldDelete);
            }

            success &= FileUtilities.ShredDirectory(directoryPath, shouldDelete);
        }
        catch
        {
            success = false;
        }
        return success;
    }

    public static bool ShredDirectory(string directoryPath, bool shouldDelete = true)
    {
        bool success = true;
        try
        {
            DirectoryInfo directoryInfo = new DirectoryInfo(directoryPath);

            string[] directoryBits = directoryPath.Split('\\');
            directoryBits[directoryBits.Length - 1] = FileUtilities.RandomName(directoryInfo.Name.Length);

            string newDirectoryPath = String.Join("\\", directoryBits);
            directoryInfo.MoveTo(newDirectoryPath);

            if (shouldDelete)
            {
                directoryInfo.Delete();
            }
        }
        catch
        {
            success = false;
        }
        return success;
    }

    public static bool ShredFile(string filePath, bool shouldDelete = true)
    {
        bool success = true;
        try
        {
            FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Write);
            for (long i = 0; i < fs.Length; i++)
            {
                fs.WriteByte((byte)Randomizer.Next(0, 255));
            }
            fs.Close();

            FileInfo fileInfo = new FileInfo(filePath);
            fileInfo.MoveTo(fileInfo.DirectoryName + @"\" + FileUtilities.RandomName(fileInfo.Name.Length));

            if (shouldDelete)
            {
                fileInfo.Delete();
            }
        }
        catch
        {
            success = false;
        }
        return success;
    }

     private static string RandomName(int length)
     {
         string fileNameChars = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ~!@¤#$£§%^&()+`={}][;,";
         string newFileName = String.Empty;
         for (int i = 0; i < length; i++)
         {
            newFileName += fileNameChars[Randomizer.Next(0, fileNameChars.Length)];
         }
         return newFileName;
    }
}

The usage calls for these functions as as follows:

1
2
3
bool success = FileUtilities.Shred(@"D:\Temp"); // This method will recursively shred a file / folder.
bool success = FileUtilities.ShredDirectory(@"D:\Temp"); // This method will shred the contents of a folder and the root folder.
bool success = FileUtilities.ShredFile(@"D:\Temp\test.txt"); // This method will shred a specified file.

I will not go through the code line-by-line to explain it as I feel most of the code is pretty self-explanatory. However if there are any questions feel free to post a comment.

Comments Off on File Shredder Code Sample (C# 4.0) more...

Image Encryption – Completed!

by on Jul.15, 2011, under News, Personal, Projects

It has been a while since I posted so here is an update for you guys. I should (hopefully) have some time to post some more blog posts detailing my current projects over the next week or so.

My image encryption tool (now known as PGIE – Pretty Good Image Encryption) is finally completed. Anyone wishing to test it is welcome to ask me about it.

Here is a little description that I threw together about the program.

Have you ever had a secret you wanted to hide in plain sight while still feeling secure? If so PGIE is just the program for you!

PGIE uses an innovative and unique mix of new and traditional encryption techniques to store data within a randomly generated pixel image that can only be decoded using a special key file.

How It Works:

PGIE first encrypts the data using a Rijndael symmetric algorithm. The key used to encrypt the data is a randomly generated 1024-bit binary key that is unique to each encode.

The encrypted data is then split into sections and stored within the image. The data is then further secured by modifying the file based on the information stored within the key file. Finally the image is modified to make the original entry point unreadable.

If either the key file or encoded images are modified or damaged then the encryption is one way.

In order for a brute force attack to be successful on this encryption the whole key file image would have to be guessed precisely; every red, green, blue and alpha component would have to match the original in order for the decryption to occur successfully. This would take a very, very long time to achieve with modern computers. See the technical details section below.

Technical Data:

There are a set of 65,535 possible characters that can be used in the encryption key and the key is 1024 characters in length. This means that there are 65535^1024 possible key sets to choose from – one very large number! In the simplest terms possible – if a computer can generate a billion keys per second then it would take far, far longer than the universe has existed to forcibly break.

There are four channels for data within a PNG pixel, red, green, blue and alpha. Each of these can range in value from 0-255. That means that there are 256^4 possible colour values per pixel (4,294,967,296). As the image size grows more pixels need to be correctly guessed in order to decode the image. As such each added pixel makes the image more difficult to decode again, making it virtually impossible to forcibly break.

Comments Off on Image Encryption – Completed! more...

CSIT – Round 2

by on Apr.09, 2011, under General, News, Personal

Hi everyone.

It has been a while since I last posted. Unfortunately my recent work with CCC has kept me busy and away from my personal projects. However as I currently have some spare time I have decided to revive the old CSIT project and revisit the idea.

I will be starting work on the project in short order (probably tomorrow or later next week). The project will probably still be called CSIT (Complete System Information Tool-kit) and will be similar to the old ideas for CSIT but not identical.

I am currently working on the plans for the design and core code ideas. The project will be based around C++, ASM, C# and WPF.

Comments Off on CSIT – Round 2 more...

TNDA – A new tool site for Neopets

by on Jan.15, 2011, under Personal, Projects

Hi everyone!

Just a quick update. Firstly happy new year since this is my first post for this year.

I’m currently working on a new site that will give Neopets users some interesting new tools to play with. I will post more details about it as I decide what features will be there – but in the mean time any suggestions and requests are welcome.

I will be focusing much of my efforts on statistic related items – trying to determine how the random events and so fourth work.

Comments Off on TNDA – A new tool site for Neopets more...

US – The Worlds Copyright Police – Update

by on Nov.26, 2010, under General, News

This is a follow-up to the article I posted earlier this year.

The US have now started seizing domain names, against the wishes of their own people and the rest of the world. They need to be taught a lesson, that they are not gods and do not control the fate of the internet. The WORLD Wide Web should remain as such, a global system. Allowing one country to selectively control and censor it would make the internet far less useful and would become a politician weapon.

This needs to stop, right now. For the moment they have started taking control over torrent site domain names, which can be easily corrected by using the hosts file – which I will describe in a later post.

To anyone living in the US who may be reading, if you value freedom on the internet please protest to whomever you think can help.

You can read the full article on torrent freak here.

Comments Off on US – The Worlds Copyright Police – Update more...

TCE – Website Edition

by on Nov.20, 2010, under Personal, Projects

Hi everyone!

I have moved the TCE project from being a C# program into a web based project instead, I am currently working on a basic design and implementation before I release the website for public viewing.

If anyone is interested in helping or beta testing the project then please feel free to contact me.

Comments Off on TCE – Website Edition more...

New Project – TCE – The Chemistry Explorer

by on Oct.05, 2010, under News, Personal, Projects

Hi everyone!

Here I am, writing about yet another one of my projects. This time I have decided to work on a program relating to a subject that is both close to my heart and one that some people find difficult to understand – chemistry.

I am thus building a tool to help people understand and solve chemistry related issues, it comes with a periodic table (as shown below) a chemistry calculator as well as some other features. As always I am open to suggestions and help should you wish to contribute either.

I will post developments on this project as I complete or start work on various parts of it so stay tuned for more! (Yes, I did copy the colours from the Wikipedia Periodic Table but I am colour blind so that was the best I could do under the circumstances!)

Current Periodic Table Display (v1)

Comments Off on New Project – TCE – The Chemistry Explorer more...

Image Encryption Tool – Data Format

by on Sep.28, 2010, under News, Personal, Projects

Hi Everyone!

In an earlier post I said I would explain a little about the the format used in my new data encoder and so here it is.

The images are stored in PNG, not any other type of format, because PNG supports full alpha transparency. The data is encoded by converting the text into binary data and then these are converted into pixels of colour, with the data stored in one of the 4 colour components (red, green, blue, alpha).

Certain operations are then done on this data to make it harder to recover and the remaining spaces are filled in with randomly generated pixels.

Comments Off on Image Encryption Tool – Data Format more...

Image Encryption Tool – Completed!

by on Sep.26, 2010, under News, Personal, Projects

I am pleased to announce that the new image encryption tool I was working on is now completed, boasting some new features that I will post about later. I also hope to post about the format, and how the data is stored (though I will keep some of the details hidden to ensure the format remains secure). If anyone wishes to beta test the software then please context me.

But for now I am going to get some much deserved rest. Keep an eye here for more information soon.

Comments Off on Image Encryption Tool – Completed! more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...