Click here to Skip to main content
15,890,123 members
Home / Discussions / C#
   

C#

 
GeneralRe: exception 0x800A03EC in excel Pin
abbd10-Mar-09 6:39
abbd10-Mar-09 6:39 
GeneralRe: exception 0x800A03EC in excel Pin
Rutvik Dave10-Mar-09 7:01
professionalRutvik Dave10-Mar-09 7:01 
GeneralRe: exception 0x800A03EC in excel Pin
abbd10-Mar-09 8:44
abbd10-Mar-09 8:44 
GeneralRe: exception 0x800A03EC in excel Pin
Rutvik Dave10-Mar-09 10:19
professionalRutvik Dave10-Mar-09 10:19 
Questionmail sending using proxy server Pin
anupmadathil8-Mar-09 22:36
anupmadathil8-Mar-09 22:36 
AnswerRe: mail sending using proxy server Pin
Christian Graus8-Mar-09 23:30
protectorChristian Graus8-Mar-09 23:30 
QuestionUsing BHO, how can I detect when a PDF file is opened on IE? Pin
svt gdwl8-Mar-09 21:42
svt gdwl8-Mar-09 21:42 
Questionhow to read a encrypted html? need help Pin
YiXiang_898-Mar-09 21:31
YiXiang_898-Mar-09 21:31 
Hi everyone, i need your help
This is my sym.cs file where it store the encryption part

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

namespace SecurePDFViewer
{
public class SymCrypto
{
private SymmetricAlgorithm symAlgorithm;

private static byte[] saltValue = new byte[] {213,230,110,217,191,69,82,238};
private static byte[] IV = new byte[] { 207, 177, 154, 229, 191, 104, 44, 244, 86, 12, 63, 54, 94, 9, 88, 148 };
private static int keySize = 256;
private static int pwIteration = 7;

public SymCrypto()
{
//Creates the default implementation, which is RijndaelManaged 256 bits
symAlgorithm = SymmetricAlgorithm.Create();
symAlgorithm.IV = IV;
}

public SymCrypto(string algorithmName)
{
symAlgorithm = SymmetricAlgorithm.Create(algorithmName);
symAlgorithm.KeySize = keySize;
symAlgorithm.IV = IV;
}

public byte[] EncryptData(string passphrase, byte[] plainBytes)
{
GenerateKey(passphrase);

// Define memory stream which will be used to hold encrypted data
MemoryStream memoryStream = new MemoryStream();

// Define cryptographic stream (Write mode for encryption)
CryptoStream cryptoStream = new CryptoStream(memoryStream,
symAlgorithm.CreateEncryptor(),
CryptoStreamMode.Write);

cryptoStream.Write(plainBytes, 0, plainBytes.Length);
cryptoStream.FlushFinalBlock();

byte[] cipherBytes = memoryStream.ToArray();

// Close streams
memoryStream.Close();
cryptoStream.Close();

return cipherBytes;
}

public string EncryptData(string passphrase, string plainText)
{
byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainText);
return Convert.ToBase64String(EncryptData(passphrase, plainTextBytes));
}

public byte[] DecryptData(string passphrase, byte[] cipherBytes)
{
GenerateKey(passphrase);

// Define memory stream which will be used to hold encrypted data
MemoryStream memoryStream = new MemoryStream(cipherBytes);

// Define cryptographic stream (Read mode for decryption)
CryptoStream cryptoStream = new CryptoStream(memoryStream,
symAlgorithm.CreateDecryptor(),
CryptoStreamMode.Read);

byte[] plainBytes = new byte[cipherBytes.Length];
int count = cryptoStream.Read(plainBytes, 0, plainBytes.Length);

// Close streams
memoryStream.Close();
cryptoStream.Close();

byte[] actualBytes = new byte[count];
for (int i = 0; i < count; i++)
{
actualBytes[i] = plainBytes[i];
}

return actualBytes;
}

public string DecryptData(string passphrase, string cipherText)
{
byte[] cipherTextBytes = Convert.FromBase64String(cipherText);
return Encoding.UTF8.GetString(DecryptData(passphrase, cipherTextBytes), 0, 1000);
}

private void GenerateKey(string passphrase)
{
Rfc2898DeriveBytes pwdGen = new Rfc2898DeriveBytes(passphrase, saltValue, pwIteration);
symAlgorithm.Key = pwdGen.GetBytes(keySize/8);
}
}
}


------------------------------------------------------------------------------------------------------


Main.cs

using System.IO;
using System.Security.Cryptography;

private void button1_Click(object sender, EventArgs e)
{
SymCrypto sym = new SymCrypto();

string cipherText = sym.EncryptData("I love Java", "2.1 SCOPE OF TESTS\nThe test plan for User Authentication System webservice will consist \nof the following tests related to interoperability: a) WS-I Basic Profile 1.1 Interoperability Tests Interoperability testing will be performed in conformance to WS-I Basic Profile 1.1 specifications. The profile addresses the following areas: \n• Messaging Messaging includes XML Representation of SOAP Messages, SOAP Processing Model and use of SOAP in HTTP. Four specifications are referenced in this section:• Simple Object Access Protocol (SOAP) 1.1• Extensible Markup Language (XML) 1.0 (Second Edition)• RFC26116 Hypertext Transport Protocol HTTP/ 1.1 • RFC2965: HTTP State Management Mechanism• Service DescriptionThis refers to Web Services Description Language (WSDL) to enable the description of services as sets of endpoints operating on messages. Three specifications and extensibility points are referenced in this section:• Web Services Description Language 1.1• XML Schema Part 1: Structures•"); <---- HARD CODE
string abc = ("how are you"); <-- HARD CODE
MessageBox.Show(cipherText + abc);
string plainText = sym.DecryptData("I love Java", cipherText);
MessageBox.Show(plainText + abc);
}


------------------------------------------------------------------------------------------------------






I will be using a IE toolbar button to mark it...
But how can change it so that i can read the encrypted html?


Thank you
AnswerRe: how to read a encrypted html? need help Pin
Christian Graus8-Mar-09 23:28
protectorChristian Graus8-Mar-09 23:28 
GeneralRe: how to read a encrypted html? need help Pin
YiXiang_898-Mar-09 23:58
YiXiang_898-Mar-09 23:58 
GeneralRe: how to read a encrypted html? need help Pin
YiXiang_898-Mar-09 23:58
YiXiang_898-Mar-09 23:58 
Questioncan u plz tell me that whether we can import microsoft word objects(lines,circles,etc...) into the microsoft .net framework. how to do that one? Pin
Kanchan Pawar8-Mar-09 21:30
Kanchan Pawar8-Mar-09 21:30 
AnswerRe: can u plz tell me that whether we can import microsoft word objects(lines,circles,etc...) into the microsoft .net framework. how to do that one? Pin
Ashfield8-Mar-09 21:55
Ashfield8-Mar-09 21:55 
JokeRe: can u plz tell me that whether we can import microsoft word objects(lines,circles,etc...) into the microsoft .net framework. how to do that one? Pin
ABitSmart8-Mar-09 22:09
ABitSmart8-Mar-09 22:09 
AnswerRe: can u plz tell me that whether we can import microsoft word objects(lines,circles,etc...) into the microsoft .net framework. how to do that one? Pin
Pete O'Hanlon8-Mar-09 23:09
mvePete O'Hanlon8-Mar-09 23:09 
AnswerRe: can u plz tell me that whether we can import microsoft word objects(lines,circles,etc...) into the microsoft .net framework. how to do that one? Pin
Christian Graus8-Mar-09 23:19
protectorChristian Graus8-Mar-09 23:19 
Questioncan u please send me that autodiagramer software Pin
Kanchan Pawar8-Mar-09 21:26
Kanchan Pawar8-Mar-09 21:26 
AnswerRe: can u please send me that autodiagramer software Pin
Ashfield8-Mar-09 21:57
Ashfield8-Mar-09 21:57 
AnswerRe: can u please send me that autodiagramer software Pin
Christian Graus8-Mar-09 23:21
protectorChristian Graus8-Mar-09 23:21 
QuestionListView Pin
Sajjad Leo8-Mar-09 21:22
Sajjad Leo8-Mar-09 21:22 
AnswerRe: ListView Pin
Christian Graus8-Mar-09 23:37
protectorChristian Graus8-Mar-09 23:37 
QuestionFill Combo With only Year value Pin
Saiyed Alam8-Mar-09 20:35
Saiyed Alam8-Mar-09 20:35 
AnswerRe: Fill Combo With only Year value Pin
Christian Graus8-Mar-09 20:36
protectorChristian Graus8-Mar-09 20:36 
GeneralRe: Fill Combo With only Year value Pin
Saiyed Alam8-Mar-09 20:54
Saiyed Alam8-Mar-09 20:54 
GeneralRe: Fill Combo With only Year value Pin
Christian Graus8-Mar-09 23:35
protectorChristian Graus8-Mar-09 23:35 

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.