bugGNU Octave - Bugs: bug #62919, base64_decode() cannot decode...

 
 

bug #62919: base64_decode() cannot decode base64_encode() content

Submitter:  Yu Hongbo <yuhongbo>
Submitted:  Fri 19 Aug 2022 01:15:03 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 6.4.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 19 Aug 2022 02:38:42 PM UTC, comment #2: 

Oops. Forgot that in the second example `input = int8 ('[1,2,3]');`.

Markus Mützel <mmuetzel>
Group administrator
Fri 19 Aug 2022 02:37:26 PM UTC, comment #1: 

Confirmed with Octave 7.2.0 on Windows.

However, as the documentation states:
https://docs.octave.org/v7.2.0/Base64-and-Binary-Data-Transmission.html

> Encode a double matrix or array x into the base64 format string s.


So, it is only meant to work for double matrix input (not int8 like in your example).

The following (Matlab compatible) functions work for me for the input in your example:

result = matlab.net.base64encode (int8 ('[0,1,2]'))
char (matlab.net.base64decode (result))


However, that is a new function in Octave 7.

In older versions, the workaround is a bit more involved:

result = base64_encode (typecast ([input, zeros(1, 8-mod(numel(input), 8))], 'double'))
char (typecast (base64_decode (result), 'int8'))


You might still need to strip padding zeros from the result at the end.

Anyway, closing as invalid because this is not supposed to work according to the function documentation.

Markus Mützel <mmuetzel>
Group administrator
Fri 19 Aug 2022 01:15:03 PM UTC, original submission:  

I encode an int8 vector, and cannot decode the encoded result. Here is my code:

>> result='[0,1,2]'

result = [0,1,2]

>> result=base64_encode(int8(result))

result = WzAsMSwyXQ==

>> result=base64_decode(result)

error: base64_decode: incorrect input size

Yu Hongbo <yuhongbo>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by yuhongbo (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-08-19 mmuetzel StatusNone Invalid / Not an Octave Bug
        Open/ClosedOpen Closed
        Operating SystemGNU/Linux Any

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code