Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is there a mismatch in base85 between Dart and Python?

Python code

from base64 import b85decode
from base64 import b85encode
encoded=b85encode(b'Hello, world!!!!')
print(encoded.decode('utf-8'))

Output:

'NM&qnZ!92pZ*pv8At50l'

Dart code

import 'dart:io';
import 'dart:typed_data';
import 'package:base85/base85.dart';

void main() {
  var codec = Base85Codec(Alphabets.z85);
  var encode = codec.encode(Uint8List.fromList('Hello, world!!!!'.codeUnits));
  print(encode);
}

Output:

nm=QNz.92Pz/PV8aT50L

Letter case is swapped between upper and lower, and non-letters are also mapped differently.

I may be missing something.

like image 716
Sumit Kumar Avatar asked Mar 23 '26 07:03

Sumit Kumar


1 Answers

Because you are not actually using ascii85 in the dart example at all. Compare this (requires pip install pyzmq*):

from zmq.utils import z85
z85.encode(b"Hello, world!!!!")
#  b'nm=QNz.92Pz/PV8aT50L'

z85 and ascii85 are subtly different.

*pip show zmq reveals: Summary: You are probably looking for pyzmq... Requires: pyzmq. Thanks to @SumitKumar for the catch.

References:

https://rfc.zeromq.org/spec/32/

like image 97
2e0byo Avatar answered Mar 25 '26 20:03

2e0byo