June 8, 2012

Encrypt Text file

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Collections.Specialized;
using System.Security.Cryptography;

namespace Helpers
{
    public class EncryptionHelper
    {

        public static void EncryptTextToFile(string Data, string FileName, string key)
        {
            FileStream fStream = null;
            CryptoStream cStream = null;
            StreamWriter sWriter = null;

            try
            {
                fStream = File.Open(FileName, FileMode.Create);
                byte[] keyArray;

                MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
                keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
                hashmd5.Clear();

                TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
                tdes.Key = keyArray;
                tdes.Mode = CipherMode.ECB;
                tdes.Padding = PaddingMode.PKCS7;

                ICryptoTransform cTransform = tdes.CreateEncryptor();

                cStream = new CryptoStream(fStream, cTransform, CryptoStreamMode.Write);
                sWriter = new StreamWriter(cStream, UTF8Encoding.UTF8);
                sWriter.WriteLine(Data);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

                sWriter.Close();
                fStream.Close();
                cStream.Close();
            }
        }


        public static string DecryptTextFromFile(String FileName, string key)
        {

            FileStream fStream = null;
            CryptoStream cStream = null;
            StreamReader sReader = null;
            string val = null;

            try
            {
                fStream = File.Open(FileName, FileMode.OpenOrCreate);
                byte[] keyArray;

                MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
                keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
                hashmd5.Clear();

                TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
                tdes.Key = keyArray;
                tdes.Mode = CipherMode.ECB;
                tdes.Padding = PaddingMode.PKCS7;

                ICryptoTransform cTransform = tdes.CreateDecryptor();
                cStream = new CryptoStream(fStream, cTransform, CryptoStreamMode.Read);
                sReader = new StreamReader(cStream, UTF8Encoding.UTF8);

                val = sReader.ReadToEnd();
            }
            catch (Exception ex)
            {
                fStream.Close();
                throw ex;
            }
            finally
            {
                if (sReader != null)
                    sReader.Close();
                if (cStream != null)
                    cStream.Close();
                if (fStream != null)
                    fStream.Close();
            }

            return val;
        }


    }
}

June 5, 2012

APTET 2012 Key

Today Andhra Pradesh Teacher Eligibility Test 2012 released preliminary key, and result will be announced in 3rd weak of this month.

Paper Wise Final Key
APTET MAY-2012
PAPER-I PAPER-II
(Mathematics & Science)
PAPER-II
(Social Studies)
Telugu
A B C D
Telugu
A B C D
Telugu
A B C D
Urdu
A B C D
Urdu
A B C D
Urdu
A B C D
Hindi
A B C D
Hindi
A B C D
Hindi
A B C D
Kannada
A B C D
Kannada
A B C D
Kannada
A B C D
Marathi
A B C D
Marathi
A B C D
Marathi
A B C D
Oriya
A B C D
Oriya
A B C D
Oriya
A B C D
Tamil
A B C D
Tamil
A B C D
Tamil
A B C D
Bengali
A B C D
Sanskrit
A B C D
Sanskrit
A B C D
submit your abjections on or before 12th June 2012
http://aptetmay2012.cgg.gov.in/objections.aptet