vbakke / trytes

Converting between trytes and bytes
6 stars 1 forks source link

Decode bytes into tryte does not work #4

Closed vbakke closed 6 years ago

vbakke commented 6 years ago

The decodeTryteStringFromBytes() fails converting my bytes into trytes.

I have encoded the tryte 'A9Z' to [1, 78, 255], and encrypted it to [22, 249, 151].

Calling decodeTryteStringFromBytes([22, 249, 151]) returns "V9". Calling encodeTryteStringAsBytes("V9") returns [22, 0, 254].

vbakke commented 6 years ago

You're correct. Encoding trytes to bytes, gives you bytes within the range of 0-242.

However, when encrypting the bytes, you get bytes in the whole range of 0-255. Therefore, you cannot decode "tryte bytes", since they are no longer just that.

I will create a new set of function that will encode full bytes into tryte strings that you can use.