Coder Social home page Coder Social logo

lua-filecoin's Introduction

Multihash

There is a basic implementation of multihash here as seen in multihash.lua and test-multihash.lua.

Currently this supports the following multihash types: identity, sha, sha2-256, sha2-512, blake2b-* (8-512), and blake2s-* (8-256).

Usage sample:

local Multihash = require 'multihash'

-- Multihash.encode(input, hash-name, [length-override]) -> multihash, hash-name
local multihash = Multihash.encode('Hello World', 'blake2b-256')

-- Multihash.decode(multihash, [index]) -> hash, hash-name, index
local hash, name = Multihash.decode(multihash)

-- Multihash.verify(input, multihash, [index]) -> verified, index
assert(Multihash.verify('Hello World', multihash), 'Multihash mismatch')

The actual implementations of the hash functions are hand-written in lua using luajit's bit and ffi libraries. See sha256.lua, sha512.lua, sha1.lua, blake2b.lua, and blake2s.lua for details. The main module lazy requires these so only hashes actually used at runtime are ever loaded and compiled.

Multibase

There is a basic implementation of multibase here as seen in multibase.lua and test-multibase.lua.

Currently this supports the following multibase encodings: identity, base2, base8, base10, base16, base16upper, base32, base32upper, base32pad, base32padupper, base32hex, base32hexupper, base32hexpad, base32hexpadupper, base32z, base58flickr, base58btc, base64, base64pad, base64url, and base64urlpad.

Usage sample:

local Multibase = require 'multibase'

-- Multibase.encode(raw, name-or-code) -> encoded, name
local encoded = Multibase.encode('Hello World', 'hex')

-- Multibase.decode(encoded) -> raw, name
local original = Multibase.decode(encoded)

The actual implementations of the base functions are hand-written in lua using luajit's bit and ffi libraries. See base-2.lua, base-8.lua, base-16.lua, base-32.lua, base-64.lua, and base-x.lua for details. The main module lazy requires these so only bases actually used at runtime are ever loaded and compiled.

lua-filecoin's People

Contributors

creationix 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.