GithubHelp home page GithubHelp logo

zunosaki / md5_file_checksum Goto Github PK

View Code? Open in Web Editor NEW

This project forked from albemala/md5_file_checksum

0.0 0.0 0.0 130 KB

A Flutter plugin for getting the MD5 hash of a file

License: MIT License

Shell 2.08% Ruby 9.33% Objective-C 17.42% Java 11.13% Kotlin 8.05% Dart 38.77% Swift 13.22%

md5_file_checksum's Introduction

Notice

This project is archived and I won't update it any more.

I have run some performance tests to compare this implementation with a pure Dart one using Flutter 3 and Dart 2.17. The results of the 2 methods are comparable and in the same order of magnitude. Therefore, in my opinion, a native implementation is not needed any more to calculate a file checksum.

A Dart implementation could be like:

Future<String?> getFileChecksum(String filePath) async {
  final file = File(filePath);
  if (!file.existsSync()) return null;
  try {
    final stream = file.openRead();
    final hash = await md5.bind(stream).first;
    // NOTE: You might not need to convert it to base64
    return base64.encode(hash.bytes);
  } catch (exception) {
    return null;
  }
}

md5_file_checksum

Pub

Flutter plugin to calculate a file checksum as MD5 hash, using a platform native implementation.

Revamped version of md5_plugin.

Usage

try {
  final fileChecksum = await Md5FileChecksum.getFileChecksum(filePath: filePath);
} catch (exception) {
  print('Unable to generate file checksum: $exception');
}

Result

Simulator Screen Shot - iPhone 13 - 2021-10-31 at 15 22 06

md5_file_checksum's People

Contributors

albemala avatar chesterkwan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.