This is a
playground to test code. It runs a full
Node.js environment and already has all of
npm’s 1,000,000+ packages pre-installed, including
cryptomancy-shard with all
npm packages installed. Try it out:
This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.
For secret-sharing schemes which need support for threshold recombination there's cryptomancy-secret. If your needs are incredibly simple, this module may provide a simpler option.
Its goal is to be:
// the API takes and outputs Uint8Arrays // so you'll probably want to convert between that and different formats var Format = require("cryptomancy-format"); // it expects you to supply your own randomness // so it can be deterministic if that suits your needs // otherwise use a cryptographically secure source of random bytes var Source = require("cryptomancy-source"); var secure_bytes = Source.bytes.secure(); var plaintext = "PEW PEW PEW"; var u8_message = Format.decodeUTF8(plaintext); // load the library var Shard = require("cryptomancy-shard"); // split the plaintext up into 5 shards // all of which are necessary to reproduce the original value var shards = Shard.split(secure_bytes, u8_message, 5); // print out your shards in whatever format you like // I like base64 because they're probably not valid UTF8 // and I don't like hex console.log(shards.map(Format.encode64)); // join the shards // order doesn't matter because internally it's just xor'ing the values var recovered = Format.encodeUTF8(Shard.join(shards)); console.log(recovered);