Convert String into byte and vice versa

Hi,

I want to know how can i convert byte array into string and then that string again back to the same equivalent byte array.
I tried this:
string str = Convert.ToBase64String(cipherText);
byte[] sampleVar = Encoding.ASCII.GetBytes(str);
But it seems that sampleVar is not equivalent to cipherText which is actually of the type byte[] :(.
Any help...
I am actually using the thing in TDES encryption where i have cipherText stored as string then i load it to string variable and need to convert it nto byte array again .. but it gives bad data. If i dont do the conversion ... (which i have to do practically to store the cipherText in database) ... then it works fine. So i believe the conversion is not proper.
Please Suggest,
Imran
U and I Solutions,
http://www.uandisolutions.com
0
imran
3/18/2005 5:33:00 AM
asp.net.getting-started 91979 articles. 4 followers. Follow

1 Replies
1543 Views

Similar Articles

[PageSpeed] 26
Get it on Google Play
Get it on Apple App Store


Hello,
Sounds dumb -
but did you try just looping through the array?
and then looping the string back into an array???

good luck
take care
tony
0
pithhelmet
3/18/2005 9:43:14 PM
Reply:

Similar Artilces:

String ccomparison problem. How to convert AUTF8String (nsACString) to a regular String or vice versa
Hi, I'm having trouble comparing strings of different types in Java Script The two strings are equal when displayed in an alert popup but the "==" condition fails The two types are the following 1. nsIURI.spec http://developer.mozilla.org/en/docs/nsIURI#Attributes and 2. http://developer.mozilla.org/en/docs/nsIScriptableInputStream:read i receive a URL through nsIScriptableInputStream.read() and attempt to compare it with nsIURI.spec In this sample code, i pass in the nsIScriptableInputStream.read() as the "url" parameter, which is then compa...

String to Linq.Byte and Linq.Byte to String convertion?
 Hi, I have a field in my database as image type. I am using Linq to read/insert records.I am having little hard time inserting text(string) into the image field and then converting back to string.Do you have any suggestions? Thanks in advance,   The below example shows how to convert Linq Binary to byte If Not String.IsNullOrEmpty(HttpContext.Current.Request.QueryString("imageID")) Then Dim imageID = HttpContext.Current.Request.QueryString("imageID") Dim db As New AuctionsDataContext Dim result = From img In db.Image...

Convert from string to integer and vice versa
I’m new to Visual Basic and am developing my first web application with VB. It’s based on at skeleton script from my host provider. It’s a form where users fill in some data, which I validate with the VB script, before the data are sent with an e-mail. I’ve mostly been able to turn the skeleton script into an application which suits my needs, but I’ve run into some problems with code which should be trivial. I need to convert from string to integer and vice versa. I’ve been searching the web, and this forum, for information on how to do this. I’ve found several ways to convert...

converting arrayname to string or vice-versa
Hi, This one is puzzling me. I know it's in the faq, to not use variables for variable naming, but I find it odd that I can't get a "stringified" form of a variable name, maybe from the symbol table? Or from the B line of modules? Say I have an array like: @somename = (1,2,3,4,5); and I want to write that array to a file, but I want the file named automatically by just dropping the @ off of the @somename. How would you go about doing it? Plus, I would like to be using strict. Also the reverse: take a filename like "somename" and load it to an a...

convert byte[] to String and string to byte[] note encoding and decoding required....
hi all,        As the subject, can I have solution ofr the same.......  e'i Convert byte[] into string and strting into byte[] , can i have teh sample page.        Thanks & Regards,Murthy.          System.Text.Encoding.Unicode.GetString(ByteArray);//Byte Array to String             System.Text.Encoding.Unicode.GetBytes(String);//String to Byte ArrayWe All move to our original place.Don't forget.Imran Baloch thanks for...

RSA Encryption
Here is my goal:1. Take a string2. Encrypt it 3. Pass it as a parameter in the QueryString4. Decrypt it The value starts as a string, then is converted to a byte[] and then encrypted.  The resulting byte[] is converted to a string and send as a parameter.  The recieving page decrypts the string (creates a byte[], decrypts to a new byte[], and the value is finally parsed for its values) I am using http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemsecuritycryptographyrsacryptoserviceproviderclasstopic.asp with a small modification t...

How to append string to Response.OutputStream after string converted to byte array
Hi, I am trying to append string to Response.OutputStream property in PostRequestHandlerExecute event handler inside custom httpmodule. The goal of this implementation is to append string to output stream after the page is rendered when the response object is still held on the server. The pseudo code I wrote is the following: private void PostRequestHandlerExecute(object sender, EventArgs e) { HttpApplication application = ( HttpApplication ) sender; HttpContext context = application.Context;   string s = "This is test!"; byte[] buffer = Encoding.ASCII.GetByt...

Getting error while converting string to double: Input string was not in correct format
Select Case LocalMeasuringUnitText Case "Currency" 'do the conversion hereDim ConversionRate As Double = GetConversionRate(_LanguageID)   Dim UKValue As Double 'String.Format("{0:c}", SelectedRow(rowloop).Item("TransData").ToString()) Dim varValue As Object = NothingDim Stringvalue As Object = SelectedRow(rowloop).Item("TransData").ToString.Trim 'varValue = Double.TryParse(Stringvalue, varValue) 'CType(Stringvalue, System.Double) 'UKValue = Convert.ToDouble(Stringvalue) / GetConversionRate(ConfigurationManager.AppS...

used a c#.net to vb.net converter and am now getting a syntax error.
ok I used a cool utility at http://www.kamalpatel.net/ConvertCSharp2VB.aspx to convert some c#.net to vb.net and it spit out a bunch of code which almost works but I am getting a syntax error on this line Imports (StreamReader sr = Shadows Function)() As StreamReader(objResponse.GetResponseStream()) I tried it that way and also like Imports (StreamReader sr = Shadows Function)() As StreamReader(objResponse.GetResponseStream()) but either way gave the same error Compiler Error Message: BC30035: Syntax error. Source Error: Line 26: Line ...

Converting bytes to string
Hi guys,I'm currently trying to insert image into my SQL db.  I have tried a number of methods that were posted online, and so far with no luck.My current code reads:                     Dim conn As New Data.SqlClient.SqlConnection()                    conn.ConnectionString = ConfigurationManager.ConnectionStrings("MainDBConnection").ToString        &nbs...

how to get start with .NET
the net help people installed  to my desktop 1-microsoft visual studio .NET enterprise developer 2003 2-microsoft .NET framework 1.1 what else do i need ...???  and how can i try with some simple code in VS.Net and run it to see wat happen...????? please help If you want to develope web applications, then you'll also need IIS on your PC.  That'll require XP-Professional or Windows 2000/2003, but XP-Home edition won't allow IIS installation. As for how to get started, you can search the web for some tutorials or buy a good book on VS.  The topic is way too vast to...

Getting Start With .net
hi i'm intersted to learn asp.net (vb or delphi) . i programming with delphi6 but i'd like to tp know something about programming in internet specially with .net . i hear about microsoft.net with delphi 7 that i can programming with delphi in .net .... is it right ? what 's our opinian about it ? and better to learn Vb.Net or continu with delphi(or delphi.net) thanks. Ali Darabian I think there is some support for Delphi in .Net. However, you will find much more support from the user community if you choose a more popular language such as VB.Net or C#. Since your al...

Converting classic to .NET 2 code, and .NET gets an error back from ADS?
 For future-proofing, our Internal Phone Directory is being moved onto our AD servers, and obviously we're using LDAP for queries.To get the phoneboook queries working, I adapted the current classic ASP code to use LDAP, and that works fine. However, we're wanting to move these pages to .NET, and that's where the problem comes in. Using the same basic logic from the Classic code (90% of its unchanged) to produce an LDAP query, I get the error  155 Unknown error (0x80005000)This is using the same website, and so the same credentials  - unless aspx pages run und...

Am I correct in thinking that the only way to get ord() to return a value over 256 is to send the character as a Unicode string instead of a byte string?
In other words, is there any character that will make ord() return over = 256 when passed in as a byte string? For example, note the differences in output between a unicode string and = a byte string regarding character 257, as a unicode string it is 257, as = a byte string it is 196. $ perl -C6 -le 'print "Character 257 info:";print "\tunicode \\x{} = notation: " . sprintf(q{\x{%x}}, 257);print "\tOutput as Unicode string = \x{101}";print "\tunicode string \\x{} notation ord(): " . = ord("\x{101}");print "\tbyte string gr...

Web resources about - Convert String into byte and vice versa - asp.net.getting-started

File:Convert to SVG and move to Commons.svg - Wikipedia, the free encyclopedia
As a courtesy (but not a requirement), please e-mail me or leave a note on my talk page if you use this image outside of Wikipedia. Thanks! As ...

Facebook Co-Founder Dustin Moskovitz Sells 450K Shares, Converts 7M More
The great Facebook stock sale frenzy continues on with a report that Co-Founder Dustin Moskovitz unloaded 450,000 shares in the social network ...

Facebook Announces “App2User” Liquidity Program for Merchants to Convert Rewards Points into Credits
... for Credits, just announced a new Credits program called “App2User,” designed to enable merchants and loyalty program operators to convert their ...

How to Convert Leads Into Buying Customers - The 9 Step Sales Process EVERYONE Should Use
... School of Business in Toronto on the topics of Sales and Entrepreneurship. I shared with them the sales process that I find How to Convert Leads ...

Bitcoin : Should I convert my savings to Bitcoin?
Answer (1 of 7): You should think of this question as "Should I invest all my savings in Bitcoin?", and not "Should I have my savings denominated ...

Convertizo 2 - Convert Units and Currency in Style on the App Store on iTunes
Get Convertizo 2 - Convert Units and Currency in Style on the App Store. See screenshots and ratings, and read customer reviews.

Catholics should not convert Jews, says Vatican, in push against anti-Semitism
... 50 years since the Vatican's repudiation of the concept of Jewish guilt for Jesus' death.  Vatican City: Catholics should not try to convert ...

Opinion: These 5 things made me a happy iPad Pro convert
... like I needed a bigger device. But after three weeks with my iPad Pro, several things have changed my mind, and I’m officially a happy convert ...

Today’s apps gone free: BlockBear, Stock Grader, PDF Smart Convert and more
Block ads and other annoying content, take the emotion out of investing, and convert almost anything into a PDF with todays collection of apps ...

How to convert your old VHS tapes to DVD with this software
Remember those old VHS tapes you have sitting in the corner? Convert them into DVDs with this affordable software so you can easily watch them ...

Resources last updated: 12/26/2015 3:53:40 AM