Pergunta

in C#:

encryptionKey="Wb2bLNGXABcl4Lz........AxqA5Xhsoqi7w52RKA=";

var key = Convert.FromBase64String(encryptionKey);

key value={89,189,155,44,209,151,0,23,37,224,188,250,186,104,35,70,250,81,212,12,106,3,149,225,178,138,162,239,14,118,68,160}

in java:

byte[] key= Base64.decodeBase64(encryptionKey);

key={89,-67,-101,44,-47,-105,0,23,37,-32,-68,-6,-70,104,-21,70,-6,81,-44,12,106,3,-107,-31,-78,-118,-94,-17,14,118,68,-96};

key value is different in Java and C#. how to get same value in Java?

Foi útil?

Solução

It's the same. In the first case bytes are unsigned and Java bytes are signed. What we see in array is different interpretation of the same value, eg 189 and -67 = 0xBD

byte b = (byte) 189;

now b = -67

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top