10
votes

Comment convertir une chaîne en un tableau d'octets hexagonales?

Duplicaté possible: strong>

Comment convertissez-vous Array d'octet à la chaîne hexadécimale, et vice versa, en C #? p>

Pour tester mon algorithme de cryptage, j'ai fourni des clés, un texte brut et leur texte de chiffrement résultant. p>

Les clés et le texte texte sont dans les chaînes p>

Comment puis-je la convertir en Heex Byte Array ?? P>

Quelque chose comme ceci: E8E9AEbeeeff0f2f3f4f5f7f8f9fa code> p>

à quelque chose comme ceci: P>

byte[] key = new byte[16] { 0xE8, 0xE9, 0xEA, 0xEB, 0xED, 0xEE, 0xEF, 0xF0, 0xF2, 0xF3, 0xF4, 0xF5, 0xF7, 0xF8, 0xF9, 0xFA} ;


2 commentaires

Dupliquer de Stackoverflow.com/questions/321370/ ...


Dupliquer de Stackoverflow.com/Questtions/311165/... aussi. Tho Il y a différentes solutions montrées là-bas, alors peut-être que tous les sujets peuvent vivre :)


3 Réponses :


16
votes

Avez-vous besoin ceci ? xxx

espère que cela aide.


0 commentaires

1
votes

exemple de code de MSDN :

string hexValues = "48 65 6C 6C 6F 20 57 6F 72 6C 64 21";
string[] hexValuesSplit = hexValues.Split(' ');
foreach (String hex in hexValuesSplit)
{
    // Convert the number expressed in base-16 to an integer.
    int value = Convert.ToInt32(hex, 16);
    // Get the character corresponding to the integral value.
    string stringValue = Char.ConvertFromUtf32(value);
    char charValue = (char)value;
    Console.WriteLine("hexadecimal value = {0}, int value = {1}, char value = {2} or {3}", hex, value, stringValue, charValue);
}


0 commentaires

0
votes

avez-vous voulu dire ceci xxx


0 commentaires