Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Extra Characters in Decoded Base64 String #51

Open
sinanouri opened this issue Aug 13, 2024 · 1 comment
Open

Issue with Extra Characters in Decoded Base64 String #51

sinanouri opened this issue Aug 13, 2024 · 1 comment

Comments

@sinanouri
Copy link

Hi, I'm decoding forward payload data but I'm getting extra characters in the decoded string:

const base64String = 'te6cckEBAQEAEQAAHgAAAABIZWxsbywgVE9OIb7WCx4=';
const decodedBase64 = TonWeb.utils.base64ToBytes(base64String);
const decodedString = new TextDecoder().decode(decodedBase64);
console.log(decodedString); // ��rAHello, TON! ��

Can anyone help me understand why extra characters are appearing in the decoded string and how to fix this issue?

@dizzycoder1112
Copy link

dizzycoder1112 commented Aug 19, 2024

Because the string is boc
you need to parse it by cell and pass the opcode by slice.loadUint(32)

const base64String = 'te6cckEBAQEAEQAAHgAAAABIZWxsbywgVE9OIb7WCx4=';
const cell = Cell.fromBase64(base64String);
console.log(cell) // x{0000000048656C6C6F2C20544F4E21}
const slice = cell.beginParse()
slice.loadUint(32)
console.log(slice.loadStringTail()); // Hello, TON!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants