c # und Java - Unterschied zwischen hmacsha256 Hash

Ich habe den folgenden Code in Java:

byte[] secretKey = secretAccessKey.getBytes("UTF-8");
SecretKeySpec signingKey = new SecretKeySpec(secretKey, "HmacSHA256");
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(signingKey);
byte[] bytes = data.getBytes("UTF-8");
byte[] rawHmac = mac.doFinal(bytes);
String result = javax.xml.bind.DatatypeConverter.printBase64Binary(rawHmac);

und den folgenden Code in C #:

UTF8Encoding enc = new UTF8Encoding();
byte[] secretKey = enc.GetBytes(secretAccessKey);
HMACSHA256 hmac = new HMACSHA256(secretKey);
hmac.Initialize();
byte[] bytes = enc.GetBytes(data);
byte[] rawHmac = hmac.ComputeHash(bytes);
string result = Convert.ToBase64String(rawHmac);

Die Bytearrays "secretKey" und "bytes" sind äquivalent, aber das Bytearray "rawHmac" und die Zeichenfolge "result" sind unterschiedlich. Kann jemand sehen, warum?

Antworten auf die Frage(2)

Ihre Antwort auf die Frage