Your C# code:
ret[i] = byte.Parse(hash.Substring((reversed ? ret.Length - i - 1 : i) * 3, 3));
Means if the
reversed
flag is false then use the next byte in sequence.
Your Javascript code:
byte[i] = await Buffer.from(hash.substring((byte.length - i - 1) * 3, 3))
Is selecting the source data bytes in reverse order. Just use the value of
i
as the offset, thus:
byte[i] = await Buffer.from(hash.substring((i) * 3, 3))