Skip to content

Problem with hex-encode/hex-decode with "bigger" streams #43

@mueckl

Description

@mueckl

Hi there,

Maybe it's not a bug or just undocumented or it has to do with linux STDIN-buffering
I have following problem with hex-encode and hex-decode using pipes.

user@host:~/tests$ sttr version
0.2.21

## OK case
## 31 kByte File - everything is ok

user@host:~/tests$ dd if=/dev/random of=random_file.bin bs=1k count=31
31+0 records in
31+0 records out
31744 bytes (32 kB, 31 KiB) copied, 0.00068615 s, 46.3 MB/s


user@host:~/tests$ sttr hex-encode random_file.bin | sttr hex-decode > copy.bin

## Error case
## 32 kByte File - error occurs
                                          
user@host:~/tests$ dd if=/dev/random of=random_file.bin bs=1k count=32
32+0 records in
32+0 records out
32768 bytes (33 kB, 32 KiB) copied, 0.00306848 s, 10.7 MB/s


user@host:~/tests$ sttr hex-encode random_file.bin | sttr hex-decode > copy.bin
Error: encoding/hex: invalid byte: U+000A
Usage:
  sttr hex-decode [string] [flags]

Aliases:
  hex-decode, hex-dec, hexadecimal-decode

Flags:
  -h, --help   help for hex-decode

## same file decode using a temp-file - no error

user@host:~/tests$ sttr hex-encode random_file.bin > temp.hex                  
user@host:~/tests$ sttr hex-decode temp.hex > copy.bin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions