SuperKingCheese
Junior Member
- Sep 17, 2019
- 140
- 86
I hope someone might be able to help me with this.
A website I am using converts peoples user names to some kind of array, that I am trying to replicate.
I think it is uint8 but when I try to convert my user name to uint8 it doesn't match what is on the website and I have no idea how to get the correct array for my username.
My user name is mp3ay.wam and the array generated by the website is 0,0,144,134,3,111,70,149
I believe this is the code that the website is using to create this array:
/* uint8array to / from hex strings */
const fromHexString = hexString =>
new Uint8Array(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
const toHexString = bytes =>
bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '');
const nameToInt = (name) => {
const sb = new Serialize.SerialBuffer({
textEncoder: new TextEncoder,
textDecoder: new TextDecoder
});
sb.pushName(name);
const name_64 = new Int64LE(sb.array);
return name_64 + '';
}
const nameToArray = (name) => {
const sb = new Serialize.SerialBuffer({
textEncoder: new TextEncoder,
textDecoder: new TextDecoder
});
sb.pushName(name);
return sb.array;
}
const intToName = (int) => {
int = new Int64LE(int);
const sb = new Serialize.SerialBuffer({
textEncoder: new TextEncoder,
textDecoder: new TextDecoder
});
sb.pushArray(int.toArray());
const name = sb.getName();
return name;
}
Can anyone help me understand what is going on here?
A website I am using converts peoples user names to some kind of array, that I am trying to replicate.
I think it is uint8 but when I try to convert my user name to uint8 it doesn't match what is on the website and I have no idea how to get the correct array for my username.
My user name is mp3ay.wam and the array generated by the website is 0,0,144,134,3,111,70,149
I believe this is the code that the website is using to create this array:
/* uint8array to / from hex strings */
const fromHexString = hexString =>
new Uint8Array(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
const toHexString = bytes =>
bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '');
const nameToInt = (name) => {
const sb = new Serialize.SerialBuffer({
textEncoder: new TextEncoder,
textDecoder: new TextDecoder
});
sb.pushName(name);
const name_64 = new Int64LE(sb.array);
return name_64 + '';
}
const nameToArray = (name) => {
const sb = new Serialize.SerialBuffer({
textEncoder: new TextEncoder,
textDecoder: new TextDecoder
});
sb.pushName(name);
return sb.array;
}
const intToName = (int) => {
int = new Int64LE(int);
const sb = new Serialize.SerialBuffer({
textEncoder: new TextEncoder,
textDecoder: new TextDecoder
});
sb.pushArray(int.toArray());
const name = sb.getName();
return name;
}
Can anyone help me understand what is going on here?