473,320 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Hex Converter Problem

Hey All,

I know this is probably stupid question. This is what I am trying to do:

I am trying to encrypt using Twofish then I take each character and change
it into the Hex value for it. Here is what I have:

Twofish tf = new Twofish();

tf.Mode = CipherMode.ECB;

byte[] plainText = Twofish.StrToByteArray(this.TextBoxEnter.Text);

System.IO.MemoryStream ms = new System.IO.MemoryStream();

ICryptoTransform encrypt = tf.CreateEncryptor(plainText);

//Create Crypto Stream that transforms file stream using twofish encryption

CryptoStream cryptostream = new
CryptoStream(ms,encrypt,CryptoStreamMode.Write);

//write out Twofish encrypted stream

cryptostream.Write(plainText,0,plainText.Length);

cryptostream.Close();

byte[] bytOut = ms.ToArray();

string output = Twofish.ByteArrayToStr(bytOut);

//Here is where I need to convert it to hex

//Lets say the output string is #4ff&* I need to change

//Hex of each character
Nov 16 '05 #1
1 1562
It isn't clear what you are trying to convert. It also isn't clear how
any of your included code is relevant.

State the question like this: I want a fuctino that takes an input of
data type X, that looks like Y. I would like the output to be of data
type A, and look like B. And tell us what X, Y, A, and B are.

Generally, if you are trying to convert a numeric value to a hex string
(which I'm not sure if you do), you can pass "X" to a ToString() method
that accepts a format string.

For example:

Byte b = 255;
Console.WriteLine(b.ToString("X"));

output:
FF

Sean McKaharay wrote:
Hey All,

I know this is probably stupid question. This is what I am trying to do:

I am trying to encrypt using Twofish then I take each character and change
it into the Hex value for it. Here is what I have:

Twofish tf = new Twofish();

tf.Mode = CipherMode.ECB;

byte[] plainText = Twofish.StrToByteArray(this.TextBoxEnter.Text);

System.IO.MemoryStream ms = new System.IO.MemoryStream();

ICryptoTransform encrypt = tf.CreateEncryptor(plainText);

//Create Crypto Stream that transforms file stream using twofish encryption

CryptoStream cryptostream = new
CryptoStream(ms,encrypt,CryptoStreamMode.Write);

//write out Twofish encrypted stream

cryptostream.Write(plainText,0,plainText.Length);

cryptostream.Close();

byte[] bytOut = ms.ToArray();

string output = Twofish.ByteArrayToStr(bytOut);

//Here is where I need to convert it to hex

//Lets say the output string is #4ff&* I need to change

//Hex of each character

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: techy techno | last post by:
hii Experts..!! I need someone to tell me where I can get a Currency Converter like http://cconv.textor.com please can someone tell me where I can get it I need it for free + I dont need...
5
by: jorfei | last post by:
I have written a component with a property IPAdrress of type System.Net.IPAddress. To ease the configuration of the component at design time, I have written a type converter for the type...
6
by: Kerry Sanders | last post by:
I am working on a project for work where I need a specialized type converter to convert the value of a string which is edited in a grid back to the underlying object type from the cell. The value...
2
by: TheMadHatter | last post by:
does anybody know of a half decent converter????? I tried the "VBConversions VB.Net to C# Converter" with less than satisfactory results, and an unnecisary hole in the bank.
0
by: Max Power | last post by:
I'm having some trouble with an RTF converter called Logictran R2Net when two users access my site simultaneously. My application simply runs an SQL query (based on parameters typed by user) that...
1
by: Nikola | last post by:
Hellooo! Can someone help me please. I tipe this code and it don't work!!! Whyyyyyy. <html> <head> <title>Text object value</title> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> <!--...
3
by: rmorvay | last post by:
I am in need of a .net component that will accept different file types across the spectrum and convert them to pdf. Any suggestions of a good company and component that I should research? I need...
12
by: Tana | last post by:
Hi, My company wants to migrate all our apps from vb.net to c#. Can someone recommend a good migrate/convert tool? I am hoping that such a tool can do a 90-95% work for me, and I will do the...
10
by: esha | last post by:
I tried several online converters. In many case they do the job, but sometimes give some mess. I think that all converters I know are old, were created for VS 2003 and do not understand new stuff...
15
by: MyRedz | last post by:
can anyone here show me some examples of converter like Currency converter or universal measurement converter...i tried to search but no working example..
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.