Click here to Skip to main content
15,894,405 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionGenerate Dyanamic Menu from Database Pin
skeyur6-Feb-09 0:45
skeyur6-Feb-09 0:45 
AnswerRe: Generate Dyanamic Menu from Database Pin
Abhishek Sur6-Feb-09 2:04
professionalAbhishek Sur6-Feb-09 2:04 
Questionhow to send mail and user form using asp.net [modified] Pin
nakathir6-Feb-09 0:22
nakathir6-Feb-09 0:22 
AnswerRe: how to send mail and user form using asp.net Pin
Manas Bhardwaj6-Feb-09 0:37
professionalManas Bhardwaj6-Feb-09 0:37 
GeneralRe: how to send mail and user form using asp.net Pin
nakathir6-Feb-09 0:50
nakathir6-Feb-09 0:50 
QuestionHeader Moves on onmouseover event how do i stop this ?? Pin
Docarctiss5-Feb-09 23:57
Docarctiss5-Feb-09 23:57 
AnswerRe: Header Moves on onmouseover event how do i stop this ?? Pin
Docarctiss6-Feb-09 1:37
Docarctiss6-Feb-09 1:37 
QuestionProblem in Decrypting Pin
CrazyCoder265-Feb-09 23:11
CrazyCoder265-Feb-09 23:11 
Hi i am using cryptography.While encrypting the code executes fine.but while decrypting I am getting an error "Padding is invalid and can not be removed."
My Codes are given below:
public static string Encrypt(string plainText,
                                 string passPhrase,
                                 string saltValue,
                                 string hashAlgorithm,
                                 int passwordIterations,
                                 string initVector,
                                 int keySize)
    {
        byte[] initVectorBytes = Encoding.ASCII.GetBytes(initVector);
        byte[] saltValueBytes = Encoding.ASCII.GetBytes(saltValue);
        byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainText);
        PasswordDeriveBytes password = new PasswordDeriveBytes(passPhrase,
                                                             saltValueBytes,
                                                             hashAlgorithm,
                                                             passwordIterations);
        byte[] keyBytes = password.GetBytes(keySize / 8);
        RijndaelManaged symmetricKey = new RijndaelManaged();
        symmetricKey.Mode = CipherMode.CBC;
        symmetricKey.Padding = PaddingMode.ANSIX923;
        ICryptoTransform encryptor = symmetricKey.CreateEncryptor(keyBytes, initVectorBytes);
        MemoryStream memoryStream = new MemoryStream();
        CryptoStream cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write);
        cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length);
        cryptoStream.FlushFinalBlock();
        byte[] cipherTextBytes = memoryStream.ToArray();
        memoryStream.Close();
        cryptoStream.Close();
        string cipherText = Convert.ToBase64String(cipherTextBytes);
        return cipherText;
    }

    public static string Decrypt(string cipherText,
                                 string passPhrase,
                                 string saltValue,
                                 string hashAlgorithm,
                                 int passwordIterations,
                                 string initVector,
                                 int keySize)
    {
        byte[] initVectorBytes = Encoding.ASCII.GetBytes(initVector);
        byte[] saltValueBytes = Encoding.ASCII.GetBytes(saltValue);
        byte[] cipherTextBytes = Convert.FromBase64String(cipherText);
        PasswordDeriveBytes password = new PasswordDeriveBytes(passPhrase,
                                                            saltValueBytes,
                                                            hashAlgorithm,
                                                            passwordIterations);
        byte[] keyBytes = password.GetBytes(keySize / 8);
        RijndaelManaged symmetricKey = new RijndaelManaged();
        symmetricKey.Mode = CipherMode.CBC;
        symmetricKey.Padding = PaddingMode.ANSIX923;
        ICryptoTransform decryptor = symmetricKey.CreateDecryptor(keyBytes, initVectorBytes);
        MemoryStream memoryStream = new MemoryStream(cipherTextBytes);
        CryptoStream cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read);
        byte[] plainTextBytes = new byte[cipherTextBytes.Length];
        int decryptedByteCount = cryptoStream.Read(plainTextBytes, 0, plainTextBytes.Length);
        memoryStream.Close();
        cryptoStream.Close();
        string plainText = Encoding.UTF8.GetString(plainTextBytes, 0, decryptedByteCount);
        return plainText;

    }


ARINDAM

AnswerRe: Problem in Decrypting Pin
Manas Bhardwaj5-Feb-09 23:26
professionalManas Bhardwaj5-Feb-09 23:26 
QuestionError in Web Setup Project while using Installer Class and Custom Actions "Object reference not set to an instance of an object" Pin
Vimalsoft(Pty) Ltd5-Feb-09 22:51
professionalVimalsoft(Pty) Ltd5-Feb-09 22:51 
Questionsend mail through database using asp.net Pin
Guvera5-Feb-09 22:10
Guvera5-Feb-09 22:10 
Questionconnectivity javascript Pin
JAYRAJ GIRI5-Feb-09 21:28
JAYRAJ GIRI5-Feb-09 21:28 
AnswerRe: connectivity javascript Pin
SeMartens5-Feb-09 22:19
SeMartens5-Feb-09 22:19 
AnswerRe: connectivity javascript Pin
Christian Graus5-Feb-09 22:23
protectorChristian Graus5-Feb-09 22:23 
QuestionGetting session details from webbrowser control Pin
prabhatmishra5-Feb-09 21:28
prabhatmishra5-Feb-09 21:28 
Question[Message Deleted] Pin
JAYRAJ GIRI5-Feb-09 21:26
JAYRAJ GIRI5-Feb-09 21:26 
AnswerRe: check boxes Pin
SeMartens5-Feb-09 22:03
SeMartens5-Feb-09 22:03 
AnswerRe: check boxes Pin
Christian Graus5-Feb-09 22:24
protectorChristian Graus5-Feb-09 22:24 
JokeRe: check boxes Pin
SeMartens5-Feb-09 22:28
SeMartens5-Feb-09 22:28 
GeneralRe: check boxes Pin
Christian Graus5-Feb-09 22:42
protectorChristian Graus5-Feb-09 22:42 
QuestionSqlDataSource Pin
Karthick_gc5-Feb-09 20:54
Karthick_gc5-Feb-09 20:54 
AnswerRe: SqlDataSource Pin
Christian Graus5-Feb-09 21:23
protectorChristian Graus5-Feb-09 21:23 
QuestionDateTimePicker In GridView Pin
saurabh mohal5-Feb-09 19:30
saurabh mohal5-Feb-09 19:30 
AnswerRe: DateTimePicker In GridView [modified] Pin
Pradip Kishore6-Feb-09 0:05
Pradip Kishore6-Feb-09 0:05 
GeneralRe: DateTimePicker In GridView Pin
saurabh mohal6-Feb-09 0:24
saurabh mohal6-Feb-09 0:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.