import 'dart:convert';

import 'package:archive/archive.dart';

/// Created by Haoyi on 2/5/21
///

class ArchiveUtils {
  static String compressString(String data, {bool useUtf8 = false}) {
    final bytes = utf8.encode(data);
    final gzipBytes = GZipEncoder().encode(bytes) ?? [];
    return base64Url.encode(gzipBytes);
  }

  static String decompressString(String base64String) {
    final gzipBytes = base64Url.decode(base64String);
    final bytes = GZipDecoder().decodeBytes(gzipBytes);
    return utf8.decode(bytes);
  }
}
