Thursday, July 21, 2011

Base64 Encoding and Decoding in C

 
Base64 is a method of encoding arbitrary data as plain ASCII text. It is one of the techniques employed by the MIME standard to send data other than plain text. Base64 encoding takes three bytes, each consisting of eight bits, and represents them as four printable characters in the ASCII standard. It does that in essentially two steps. 

The first step is to convert three bytes to four numbers of six bits. Base64 only uses 6 bits. The 64 characters are 10 digits (0 to 9), 26 lowercase characters (a to z), 26 uppercase characters (A to Z) as well as '+' and '/'.

For example, the three bytes are 155, 162 and 233, the corresponding bit stream is 100110111010001011101001, which in turn corresponds to the 6-bit values 38, 58, 11 and 41.


These numbers are converted to ASCII characters in the second step using the Base64 encoding table. The 6-bit values of our example translate to the ASCII sequence "m6Lp".
  • 155 -> 10011011
  • 162 -> 10100010
  • 233 -> 11101001
  • 100110 -> 38
  • 111010 -> 58
  • 001011 -> 11
  • 101001 -> 41
  • 38 -> m
  • 58 -> 6
  • 11 -> L
  • 41 -> p
This two-step process is applied to the whole sequence of bytes that are encoded. If the size of the original data in bytes is a multiple of three, everything works fine. If it is not, we might end up with one or two 8-bit bytes. For proper encoding, we have to append enough bytes with a value of '0' to create a 3-byte group. The Base64 uses '=' as a padding character.

Sample C Program

The following program in C can be used for Base64 Encoding and Decoding.



--
Sam

Sunday, July 3, 2011

How to check if your antivirus is working properly?


Here is a simple method to check if your antivirus program is working properly or not. Follow the steps below.


Open Notepad and copy the text given below.

X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*

Save file as "checkantivirus.com" including quotation-marks. (not necessary to be same as this file name, but save it in extension .com

Seconds after saving this file, your Anti-Virus should come with the message that this file is infected with virus asking permission for its deletion/clean.

This file is secure and it’s not going to infect your computer in any way. It is a standard text developed by the European Institute for Computer Anti-virus Research (EICAR). Every Anti-Virus is programmed to load this file as a virus.

If your Anti-Virus will not detecting this file as a virus, then you should probably find some other Anti-Virus up to date. It means that your PC might already being infected from viruses and your current Anti-Virus does not recognize them.


--
Sam

Tamil News Live Online HD

Tamil News Live Online HD