Hi guys,

I spent days on this problem and no one seems to have a solution.
I want to communicate with a WebService via SOAP. This WebService got a function to send and receive files, which are encoded in Base64. I found a lot of implementations of the Base64 encoder/decoder - for example this one: http://www.webtoolkit.info/javascript-base64.html
Adobe Air uses WebKit so there are also the functions atob and btoa available.

The Base64 thing should work. Now the reading of the files... I want to read any type of file - I think this function should work:
Code:
    this.readFile = function(inputfile){
        var file = new air.File(inputfile);
        var bytes = new air.ByteArray();
        if (file.exists) {
            var stream = new air.FileStream();
            stream.open(file, air.FileMode.READ);
            bytes.endian = air.Endian.LITTLE_ENDIAN;
            stream.readBytes(bytes, 0, file.size);
            stream.close();
        }
        
        return bytes;
    };
I create the Base64 string like this:
Code:
var binary = c_FileManager.readFile('Stunden.xlsx');
air.trace(encodeBase64(binary.toString()));
The created string is not correct. It almost looks right, but some Bytes seem to be interpreted not correct.

This is how it should look:
Code:
...NtWUQbCGicTcUg7osIbOa0sctUvM9eevciQlJWq8JZSMUOUIxH11fJbOcBI15tMRU5kX+QErMcSoWx82D5y8KFUhE...
This is what I get:
Code:
...NtWUQbCGicTcUg7osIbDHLVLzPXnr3IkJSVqvCWUjFDlCMR9dXyWznASNebTEVOZF/kBKzHEqFsfNg+cuFUhE...
I think the problem is how I read the files or how I use the Base64 encoder with the ByteArray type.

I don't know how I can solve the problem