Git Product home page Git Product logo

pickler's Introduction

mod-pickle

npm mod-pickle module implements the python pickle-like binary protocols for serializing and de-serializing a javascript object structure as in python

Find the demos in the demos folder

Pickle Reference: https://docs.python.org/3/library/pickle.html#module-pickle

USAGE:

const JSPickle = require("mod-pickle");

JSPickle.JSAlgorithmBasedPickler
JSPickle.JSCertificateBasedPickler
JSPickle.pypickle

JSAlgorithmBasedPickler, jsPickler

JSAlgorithmBasedPickler(algorithm, keyAlgorithm, digest, options)

jsPickler(algorithm, keyAlgorithm, digest, options)

/**
 * JSAlgorithmBasedPickler, JSPickler
 *
 * @param {*} algorithm
 * @param {*} keyAlgorithm
 * @param {*} digest
 * @param {*} options
 * @return {*}
 */

.dump

dump(path, data, salt = "secret")


let hasher = JSPickle.jsPickler();
let written = hasher.dump("./demos/test", content);

.load

load(path, salt = "secret")


const JSPickle = require("mod-pickle");
let hasher = JSPickle.jsPickler();
let read = hasher.load("./demos/test");

.unpickle

unpickle(path, salt = "secret")


let hasher = JSPickle.jsPickler();
let dehashed = hasher.unpickle("./demos/test");

pickle, pypickle

This is the original python pickle implementation.


'use strict';

const JSPickle = require("mod-pickle");

let { HIGHEST_PROTOCOL, DEFAULT_PROTOCOL, dump, load, Pickler, Unpickler } = JSPickle.pickle();
// let { HIGHEST_PROTOCOL, DEFAULT_PROTOCOL, dump, load, Pickler, Unpickler } = JSPickle.pypickle();

dump(dataObj, file, protocol, fix_imports, buffer_callback).then(v => console.log(v));
Pickler(dataObj, file, protocol, fix_imports, "buffer_callback).then(v => console.log(v));

Unpickler(file, fix_imports, encoding, errors, buffer).then(v => console.log(v));
load(file, fix_imports, encoding, errors, buffer).then(v => console.log(v));

JSCertificateBasedPickler, jsCertPickler


const hash = require("hasher-apis");

let { privateKey, publicKey } = hash._genKeyPair()

hash._dumpKeyFile("./demos/privateKey", privateKey);
hash._dumpKeyFile("./demos/publicKey", publicKey);


const JSPickle = require("mod-pickle");
const fs = require("fs");

const p3 = "./demos/test.txt";
let content = fs.readFileSync(p3, {encoding: "utf-8"});
let hashed = hash.encryptWithKey(content, { publicKeyPath: "./demos/publicKey.pem"});

let data = hash.decryptWithKey(hashed, { privateKeyPath: "./demos/privateKey.pem"});
fs.writeFileSync("./demos/programming.encryptwithkey.txt", data, { encoding: "utf-8"});


Current Status

  • In development

Todo

Check .todo file for latest TODO list

License

The MIT License (MIT) - See LICENSE for further details

Copyright ยฉ 2023 - till library works

pickler's People

Contributors

ganeshkbhat avatar

Stargazers

Felix avatar  avatar

Watchers

 avatar

pickler's Issues

Update dev/prod status in readme

Hi! Thanks for your great projects! I want to use your 'python implementation equivalent' pickler library in my project, ( https://github.com/boltex/leojs ) but I'm unsure if this is functional..?

Your user page at https://github.com/ganeshkbhat suggests that this project has a 'prod' status...

image

but the readme says this is still in 'dev'.

image

Hoping to use this soon! (if it supports pickling/unpickling up to protocol, 2) Thanks again! ๐Ÿ˜„

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.