Git Product home page Git Product logo

shibme / xipher Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 0.0 189 KB

Xipher is a curated collection of cryptographic primitives put together to perform key/password based asymmetric encryption

Home Page: https://dev.shib.me/xipher/

License: MIT License

Dockerfile 0.16% Go 94.91% HTML 0.94% PowerShell 1.77% Shell 2.22%
argon2 cryptography curve25519 password-based-encryption xchacha20-poly1305 xipher crystals-kyber post-quantum-cryptography

xipher's Introduction

Xipher

Go Reference Go Report Card Test Status Release Status License

Xipher is a curated collection of cryptographic primitives put together to perform key/password based asymmetric encryption.

What does it do?

  • Allows sharing of data securely between two parties over an insecure channel using asymmetric encryption.
  • The sender encrypts the data using a public key (received from a receiver) derived from a password and shares the encrypted data with the receiver.
  • The receiver decrypts the data using the same password.

Key Aspects

  • Encrypts data with the public key generated based on a password.
  • Supports stream cipher along with stream compression, resulting in lower memory footprint.
  • Supports post-quantum cryptography using the Kyber algorithm.

CLI

Download the latest binary from the releases page and add it to your path.

Demo

Demo

Homebrew

Xipher can be installed with brew using the following command on macOS

brew install shibme/tap/xipher

Install Script

Install Latest Version

With Shell (MacOs/Linux):

curl -fsSL https://dev.shib.me/xipher/install.sh | sh

With PowerShell (Windows):

irm https://dev.shib.me/xipher/install.ps1 | iex

Install Specific Version

With Shell (MacOs/Linux):

curl -fsSL https://dev.shib.me/xipher/install.sh | sh -s v1.1.0

With PowerShell (Windows):

$v="1.1.0"; irm https://dev.shib.me/xipher/install.ps1 | iex

Docker

You can also run Xipher without installing using Docker:

docker run --rm -v $PWD:/data -it shibme/xipher help

Web Interface

Using as a Go package

Install the package

go get -u dev.shib.me/xipher

Use it in your code

package main

import (
	"encoding/base32"
	"fmt"

	"dev.shib.me/xipher"
)

func main() {
	// Creating a new private key for password
	privKey, err := xipher.NewPrivateKeyForPassword([]byte("Paws0meKittyKuwan!"))
	if err != nil {
		panic(err)
	}

	// Deriving  public key from private key
	pubKey, err := privKey.PublicKey(false)
	if err != nil {
		panic(err)
	}
	publicKeyBytes, err := pubKey.Bytes()
	if err != nil {
		panic(err)
	}
	fmt.Println("PublicKey:", base32.StdEncoding.WithPadding(base32.NoPadding).EncodeToString(publicKeyBytes))

	platinText := []byte("Hello World!")

	// Encrypting plain text with public key
	cipherText, err := pubKey.Encrypt(platinText, true)
	if err != nil {
		panic(err)
	}
	fmt.Println("Encrypted:", base32.StdEncoding.WithPadding(base32.NoPadding).EncodeToString(cipherText))

	// Decrypting cipher text with private key
	plainText, err := privKey.Decrypt(cipherText)
	if err != nil {
		panic(err)
	}
	fmt.Println("Decrypted:", string(plainText))
}

Web Assembly

To use xipher as a web assembly (wasm) module in a browser app, follow the example below.

<html>
	<head>
		<meta charset="utf-8"/>
		<script src="https://dev.shib.me/xipher/wasm/wasm_exec.js"></script>
		<script>
			const go = new Go();
			WebAssembly.instantiateStreaming(fetch("https://dev.shib.me/xipher/wasm/xipher.wasm"), go.importObject).then((result) => {
				go.run(result.instance);
			});
		</script>
	</head>
<body>
	Call wasm methods that begin with xipher. For example: xipherNewSecretKey()
</body>
</html>

Under the hood

Xipher uses the following algorithms and libraries to achieve its functionality:

Workflow

The following sequence diagram illustrates the workflow of Xipher in encrypting data using a password based public key.

sequenceDiagram
participant RX as Xipher
actor Receiver
actor Sender
participant SX as Xipher
    Receiver-->>+RX: Derive public (inputs password)
    RX-->>-Receiver: Returns Public Key
    Receiver->>Sender: Shares Public Key
    Sender-->>+SX: Encrypt data with public key
    SX-->>-Sender: Returns ciphertext encrypted with Public Key
    Sender->>Receiver: Sends the encrypted ciphertext to the Receiver
    Receiver-->>+RX: Decrypt data (inputs ciphertext and password)
    RX-->>-Receiver: Returns decrypted data

Disclaimer

This tool/library is provided without any warranties, and there is no guarantee of its stability. Due to the experimental nature of some of its components, it is anticipated that modifications to the code, repository, and API will be made in the future. Caution is advised before incorporating this into a production application. Please report any identified security issues promptly. Your cooperation in notifying us of such concerns is highly appreciated.

xipher's People

Contributors

shibme avatar

Stargazers

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