HaxeFoundation / HaxeFoundation/haxe
[php] Wrong addbytes for BytesBuffer
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
The code below will return for Eval target:
```
1) Ki: 36363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636
2) Ki: 3636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363600000001
```
but will give wrong result for php:
```
1) Ki: 36363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636
2) Ki: 00000001
````
Here is the example:
```haxe
var Ki = new haxe.io.BytesBuffer();
var msg = Bytes.ofHex("00000001");
var key = Bytes.ofHex("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
for (i in 0...key.length) {
Ki.addByte(key.get(i) ^ 0x36);
}
trace("1) Ki: "+Ki.getBytes().toHex());
Ki.add(msg);
trace("2) Ki: "+Ki.getBytes().toHex());
```
Tested on Haxe 4.3.1
Contributor guide
Research direction
Run the provided haxe.io.BytesBuffer example for the PHP target and compare its output with the other target shown. Then trace the PHP-target implementation used by BytesBuffer.add and addBytes; done means appending the four-byte message preserves the existing bytes and produces the expected second hex value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100