PC Review


Reply
Thread Tools Rate Thread

Converting encrypted data to String

 
 
MD
Guest
Posts: n/a
 
      24th Jan 2005
Hello,
i'm using the OpenNETCF.org framework so send encrypted data from a
Pocket PC to a server.
I neeed to send the encrypted data as a String and then decrypt it.
The code:

// encode data
Byte[] encodedBytes =
des.EncryptValue(System.Text.Encoding.ASCII.GetBytes(data));
String encodedBytesAsString =
System.Text.Encoding.ASCII.GetString(encodedBytes, 0,
encodedBytes.Length);

// send data

byte[] encodedBytes2 =
System.Text.Encoding.ASCII.GetBytes(encodedBytesAsString);
byte[] decodedBytes = des.EncryptValue(encodedBytes2);
String decodedBytesAsString =
System.Text.Encoding.ASCII.GetString(decodedBytes, 0,
decodedBytes.Length);


The decryption doesn't work.
Does anyone have an idea? Does it has to do something with the ASCII
conversion?

MD
 
Reply With Quote
 
 
 
 
Dieter
Guest
Posts: n/a
 
      25th Jan 2005
for crypt and decrypt strings in VB.Net (OpenNetCF)
I use this code: ( sorry for the formatting)


Public Function get_key(ByVal string_in As String) As String

If string_in <> "" Then

Dim DES As New TripleDESCryptoServiceProvider

DES.Key = (ASCIIEncoding.ASCII.GetBytes(Mid(deviceStr,
1,24)))
DES.IV = (ASCIIEncoding.ASCII.GetBytes(Mid(deviceStr, 1,
8)))
Dim UE As New UnicodeEncoding


Dim cs As Byte() =
DES.EncryptValue(UE.Unicode.GetBytes(string_in))

Return UE.Unicode.GetString(cs, 0, CInt(cs.Length))

End If



End Function



Public Function sent_key(ByVal string_in As String) As String

If string_in <> "" Then

Dim DES As New TripleDESCryptoServiceProvider

DES.Key = (ASCIIEncoding.ASCII.GetBytes(Mid(deviceStr, 1,
24)))

DES.IV = (ASCIIEncoding.ASCII.GetBytes(Mid(deviceStr, 1,
8)))

Dim UE As New UnicodeEncoding


' Dim cs As Byte() =
DES.EncryptValue(ASCIIEncoding.ASCII.GetBytes(string_in))
Dim cs As Byte() = (UE.Unicode.GetBytes(string_in))
Dim cs2 As Byte() = DES.DecryptValue(cs)

Return UE.Unicode.GetString(cs2, 0, CInt(cs2.Length))

End If


End Function
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting A String to a Column of Data carl Microsoft Excel Worksheet Functions 3 19th May 2010 08:34 PM
converting array of byte data type to string. shivaprasad@techie.com Microsoft C# .NET 5 8th Oct 2005 12:39 AM
CryptoStream makes encrypted data bigger than original string =?Utf-8?B?QnVya2UgQXRpbGxh?= Microsoft Dot NET Framework 2 9th Feb 2004 09:48 AM
CryptoStream makes encrypted data bigger than original string =?Utf-8?B?QnVya2UgQXRpbGxh?= Microsoft C# .NET 4 9th Feb 2004 08:14 AM
Re: Converting a string to a string that contains the ASCII values of each letter in the origional string Frank Oquendo Microsoft C# .NET 0 31st Jul 2003 08:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:36 AM.