Code Monkey home page Code Monkey logo

fsblob's Introduction

fsblob Go Report CardGo Reference

File System based blob store with encryption,metadata and integrity check support

Features

Reader and Writer

Blob provides io.Reader and io.Writer interfaces to read and write binary data

	w, err := blob.Writer()
	if err != nil {
		log.Fatal(err)
	}

	r, err := blob.Reader()
	if err != nil {
		log.Fatal(err)
	}

Metadata

Blob provides APIs to store and retrieve metadata of the blob

	if err := blob.Put("key", "value"); err != nil {
		log.Fatal(err)
	}

	if v, err := blob.Get("key"); err != nil || v != "value" {
		log.Fatal("value not found")
	}

	if err := blob.PutAll(map[string]string{
		"key-1": "value-1",
		"key-2": "value-2",
	}); err != nil {
		log.Fatal(err)
	}

	m, err :=  blob.GetAll() 
	if err != nil {
		log.Fatal(err)
	}

Encryption (dual key encryption)

Blob content along with metadata can be encrypted by providing a primary encryption key. For each blob a random secondary encryption (aes256 bit) key is created to encrypt the blob content. Secondary encryption key along with the metadata is encrypted with the primary cipher.

	key := make([]byte, 32)
	if _, err := crand.Read(key); err != nil {
		log.Fatal(err)
	}

	aead, err := chacha20poly1305.New(key)
	if err != nil {
		log.Fatal(err)
	}

	bucket, err := fsblob.NewBucket(path, aead)
	if err != nil {
		log.Fatal(err)
	}

Integrity

Blobs can be sealed and verified. Once sealed, a HMAC sum of the blob content is calculated and stored in the metadata. Upon verification, the sum is verified against the blob content.

	// seal the blob
	if err := blob.Seal(); err != nil {
		log.Fatal(err)
	}

	// verify the glob
	if err := blob.Verify(); err != nil {
		log.Fatal("blob integrity compromised. error: %v", err)
	}

fsblob's People

Contributors

smitajit avatar

Watchers

 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.