Adnan’s Blog

Archive for July 2008

As a web designer, we use resources like CSS and javascript. These files should be optimized using compression for reducing the file size and hence the load time.

To decrease the file size web designers can follow 3 guidelines:

  1. Remove whitespace like tabs, spaces, blank lines, etc.
  2. Remove unused CSS classes and ID’s.
  3. Use shorthand wherever applicable. For example use #FFF instead of #FFFFFF or 0 for 0px.

There are various online tools available for CSS Compression. One of them is Clean CSS. This nifty tool, allows you to enter the css code or point it to an online css file and provides many other options along with feature to select the level of compression.

You can try it out on :

http://www.cleancss.com/

Tags:

When you pass information from one page to another, you are passing information that anybody can sniff. For example consider a scenario, in which you pass the customer id as a query string:

http://www.yourapplication.com?customer_id=15

Now if somebody replaced 15 with say 10 or any other number, they can pull up other customer information. And thats a bad for security.

One solution to this problem is to use ecryption using a secret key. So lets use a hard-to-crack 8 byte key like $zm0!qp?

To accomplish this heres a code snippet


using System;
using System.IO;
using System.Xml;
using System.Text;
using System.Security.Cryptography;

public class Encryption64
{
private byte[] key = {};
private byte[] IV = {18, 52, 86, 120, 144, 171, 205, 239};

public string Decrypt(string stringToDecrypt, string sEncryptionKey)
{
byte[] inputByteArray = new byte[stringToDecrypt.Length + 1];
try {
key = System.Text.Encoding.UTF8.GetBytes(sEncryptionKey, 8);
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
inputByteArray = Convert.FromBase64String(stringToDecrypt);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(key, IV), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
return encoding.GetString(ms.ToArray());
}
catch (Exception e) {
return e.Message;
}
}

public string Encrypt(string stringToEncrypt, string sEncryptionKey)
{
try {
key = System.Text.Encoding.UTF8.GetBytes(sEncryptionKey, 8);
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
byte[] inputByteArray = Encoding.UTF8.GetBytes(stringToEncrypt);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(key, IV), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
return Convert.ToBase64String(ms.ToArray());
}
catch (Exception e) {
return e.Message;
}
}
}

The end user will get to see a random text in the query string, something like

http://www.yourapplication.com/Receive.aspx?key=a2f5ckj?h79#8dd3

Remember stay secure stay safe.

I was designing a template for a web application and i wanted to try out something new. The user interface revolves around a compatible set of layout, colors, images and fonts. So i was Googling for a tool to help me compare Fonts and thier web compatibility. I came across a great tool called Typetester. Typetester allows you to customize and compare upto 3 fonts side by side in all variants including bold, italic, uppercase, etc simultaneously.

If you want to try it out yourself, visit http://typetester.maratz.com/

Tags:

Although we cant all be photo image editing experts, tools like this can definitely help you come very close. Picknik provides a clean and easy user interface that will get you started on tweaking your favorite images in no time. With an abundant set of Fonts, special effects and other advanced settings, this tool is a must use. The service is offered in both free and premium flavors. It also provides a decent API for developers to integrate certain features in their own applications also with some good tutorials.

Picnik Online Image Editing

http://www.picknik.com

You can also check out a Firefox plugin on https://addons.mozilla.org/en-US/firefox/addon/4889

Tags:

Prestashop is a welcome addition to the list Open source e-commerce solutions. The solution is completely configured with two sections, the front end; which deals with the online store’s user interface and the back end; which provides various tools to configure products, categories and other usual product related stuff. What sets Prestashop apart is its robustness and ease of use, making it very simple to install and configure. The upcoming versions plan on supporting Google Checkout, downloadable pdf catalogs and much more. Check it out…

Open Source e-Commerce Solution

Open Source e-Commerce Solution

If you are using Membership Provider in your ASP.net application, you might come across a scenario in which you need to have both Security Question and Answer feature and would also like to programmatically reset the password for an account.

So if you run the code

string username = “user”;
string password = “password”;
MembershipUser mu = Membership.GetUser(username);
mu.ChangePassword(mu.ResetPassword(), password);

You will get an error when you try to reset the password. A solution is to add another Membership provider having all the same settings as the default provider with only one exception:

<add name="NewMembershipProvider" requiresQuestionAndAnswer=”false” ....../>

For all Membership functions, you the default Membership provider will be used, but when you need to reset the password, you must reference the new Provider. Here’s a code excerpt to help you out:

string username = “user”;
string password = “password”;
MembershipUser mu = Membership.Providers["NewMembershipProvider"].GetUser(username, false);
mu.ChangePassword(mu.ResetPassword(), password);

So now your application can use both the Security feature to recover password and programmatically Change/Reset the password when required.