Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Loosing French characters
Message
 
À
24/06/2007 23:14:43
Information générale
Forum:
ASP.NET
Catégorie:
Cryptographie
Versions des environnements
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01235283
Message ID:
01235288
Vues:
18
This message has been marked as the solution to the initial question of the thread.
You should use Encoding.Default to get properly localized data. ASCII should be used only if you're dealing with true ASCII (lower 128 or 255 with default ASCII encoding) which is rarely the case. If you need to two way convert always use the Default Encoding which will use your machine's configured codepage to convert to and from Unicode.

+++ Rick ---

>I am using a standard .NET code to encrypt some strings. This is widely used across the net. The code supports DES, RC2, Rinjdael and TripleDes. The entry code to encrypt is as follow, with minor modifications to fit our personal needs:
>
>
>        Public Function Encrypt(ByVal data As String, ByVal userKey As String, _
>         ByVal alg As EncryptionAlgorithm) As Boolean
>            Dim cipherText As Byte()
>
>            ' Create the encryptor object, specifying 3DES as the encryption algorithm
>            Dim enc As New Encryptor(alg)
>
>            ' Get the connection string as a byte array
>            Dim plainText As Byte() = Encoding.ASCII.GetBytes(data)
>            Dim key As Byte() = Encoding.ASCII.GetBytes(userKey)
>
>            ' Perform the encryption
>            If Not enc.Encrypt(plainText, key) Then
>
>                ' Get the proper definition as per the current scope
>                If oProcess Is Nothing Then
>                    oApp.ErrorSetupControlledByTheFramework("Unable to encrypt. " + _
>                     "The message is: " + enc.cError)
>                Else
>                    oProcess.ErrorSetupControlledByTheFramework("Unable to encrypt. " + _
>                     "The message is: " + enc.cError)
>                End If
>
>                Return False
>            End If
>
>            cipherText = enc.oMemoryStreamEncryptedData
>
>            ' Store the intialization vector, as this will be required for decryption
>            Dim initVector As [String] = Convert.ToBase64String(enc.IV)
>
>            cEncrypt = initVector + " " + Convert.ToBase64String(cipherText)
>            Return True
>        End Function
>
>
>The problem I have is I just discovered that if I want to encrypt a string containing a French character that I will loose that on the decryption. Anyone would know what I would have to do, if anything could be done, to support those characters at the encryption and decryption level?
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform