I'm trying to generate the structure of a FamousWriter file (fwd). I'm halfway through the file. I'm using the WEB IDE, and I'd like to see the translation to string of the byte arrays I've found.
This should be doable with process and encoding but I'm struck by a unkown key found error.
As an example, the string:
10 00 3F 79 7D 77 3F 67 79 7E 74 7F 67 24 3E 7A 60 77
is shown in it's ASCII form:
?y}w?gy~tg$>z`w
But I know the first byte (in this case '10') it's the encryption key.
So, after processing it:
00 10 2F 69 6D 67 2F 77 69 6E 64 6F 77 34 2E 6A 70 67
And it would be shown as:
/img/window4.jpg
My code at the moment is:
- id: firstfile
type: file_name
repeat: expr
repeat-expr: 1
file_name:
seq:
- id: sizedecoder
type: u2
- id: data
size: sizedecoder
process: xor(sizedecoder)
#type: str
#encoding: SJIS
Affiliate disclaimer: I'm a Kaitai Struct maintainer (see my GitHub profile).
As of Kaitai Struct 0.10, using type: str
and process
on the same attribute hasn't been implemented yet. See https://github.com/kaitai-io/kaitai_struct/issues/503 and https://github.com/kaitai-io/kaitai_struct/issues/706#issuecomment-590125139:
2. using
process
is not implemented onstr
ing type at all. I don't think it's intentional, it's just another bug.But it's easy to work around both issues, you can also wrap it into a new user type.
So in your case, you should add a wrapper type for the string - let's call it str_wrapper
:
file_name:
seq:
- id: sizedecoder
type: u2
- id: data
size: sizedecoder
process: xor(sizedecoder)
type: str_wrapper
str_wrapper:
seq:
- id: value
size-eos: true
type: str
encoding: SJIS