Giter Site home page Giter Site logo

crc64_ecma182.js's Introduction

CRC64-ECMA182.js

Pure JavaScript implement of CRC64-ECMA182 for Node.js.

This package can be used as verify Ali-OSS file.

Installation

$ npm install --save crc64-ecma182.js

Usage

Calculate a Buffer

You can calculate the CRC64-ECMA182 value for a Node.js buffer or string:

crc64.crc64(buff[, prev]);
  • Parameters:
    • buff: the buffer or string to be calculated;
    • [prev]: if exists, prev indicates the previous CRC64-ECMA182 value; (optional)
  • Returns: the result string indicates a uint64 value that calculated.
const crc64 = require("crc64-ecma182.js");
const ret1 = crc64.crc64("123456789");
const ret2 = crc64.crc64(new Buffer("123456789"));
const ret3 = crc64.crc64("123456789", "0");
const ret4 = crc64.crc64(new Buffer("123456789"), "0");

// ret1 ~ ret2 all equals to:
//
//   '11051210869376104954'

Calculate a file

You can calculate the CRC64-ECMA182 value for a file:

crc64.crc64File(filename, callback);
  • Parameters:
    • filename: the file's name that to be calculated;
    • callback: the callback function which receives two arguments err and ret.
crc64.crc64File(path.join(__dirname, "pic.png"), function(err, ret) {
    console.log(err, ret);

    // a possible result:
    //
    //   undefined 5178350320981835788
});

Contribution

You're welcome to make pull-requests.

crc64_ecma182.js's People

Contributors

xadillax avatar

Stargazers

殷魄 avatar logan avatar moca_tao7 avatar Mutian avatar cyf avatar lindowx avatar KangKang avatar lchysh avatar 邓杰 avatar Nicola Del Gobbo avatar Yorkie Makoto avatar  avatar

Watchers

James Cloos avatar  avatar

crc64_ecma182.js's Issues

获取crc64时,报内存不足

错误信息:Aborted(Cannot enlarge memory arrays to size 35950592 bytes (OOM). Either (1) compile with -sINITIAL_MEMORY=X with X higher than the current value 16777216, (2) compile with -sALLOW_MEMORY_GROWTH which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -sABORTING_MALLOC=0)

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.