Code Monkey home page Code Monkey logo

rage-wasm's Introduction

rage-wasm: WebAssembly wrapper of rage

rage is a simple, modern, and secure file encryption tool, using the age format. It features small explicit keys, no config options, and UNIX-style composability.

The format specification is at age-encryption.org/v1. To discuss the spec or other age related topics, please email the mailing list at [email protected]. age was designed by @Benjojo12 and @FiloSottile.

This package is a WebAssembly wrapper of the Rust rage package, providing basic encryption and descryption operations.

๐Ÿšด Usage

๐Ÿ‘ Use NPM or Yarn to install the package

npm install @kanru/rage-wasm

The package exports a single module with 5 async methods. Upon first use an inlined webassembly module will be loaded asynchronously.

  • keygen - generate x25519 key pairs
  • encrypt_with_x25519
  • decrypt_with_x25519
  • encrypt_with_user_passphrase
  • decrypt_with_user_passphrase

Examples

Some examples with parcel or shadow-cljs are available under the examples/ directory.

Contribute

๐Ÿ› ๏ธ Build

npm install
npm run build

๐Ÿ”ฌ Test in Headless Browsers

npm test

๐ŸŽ Publish to NPM

npm publish

rage-wasm's People

Contributors

dependabot[bot] avatar kanru avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rage-wasm's Issues

Usage instructions? can't use

hey, trying to use this library and having problems

I tried running with node v16 and tried from an mjs file:

tried import:

import rage from '@kanru/rage-wasm';

got this:

Error: Cannot find module '@kanru/rage-wasm'

tried require

const rage = require('@kanru/rage-wasm');

and tried this in typescript

import rage from '@kanru/rage-wasm/dist/index.js';

got this:

export { decrypt_with_user_passphrase$1 as decrypt_with_user_passphrase, decrypt_with_x25519$1 as decrypt_with_x25519, encrypt_with_user_passphrase$1 as encrypt_with_user_passphrase, encrypt_with_x25519$1 as encrypt_with_x25519, keygen$1 as keygen };
^^^^^^
SyntaxError: Unexpected token 'export'

I managed to configure typescript to compile the index.js file (not sure exactly which combination of tsconfig settings led to this), after which I got this neat error:

TypeError: Cannot assign to read only property 'keygen' of object '[object Object]'

also, I'm assuming the wasm-pack build step is for development, not for end users? I don't see that binary anywhere int the npm lib.

Thanks

Unable to decrypt data that wasn't encrypted with rage-wasm

I set up a browser test doing a simple decryption as described in this project's javascript unit test. When I tried to decrypt data that was encrypted at the command line with age, I get a decryption error. I verified that I was able to decrypt the same data at the command line with both age and rage.

My test case was essentially:

age-keygen >key.txt
age -e -a -i key.txt -o encrypted.txt
const secret_key = '<pasted from key.txt>';
const encrypted_data = '<pasted from encrypted.txt>';
console.log(decode(await decrypt_with_x25519(secret_key, encode(encrypted_data))));

Where encode and decode are copied from ./tests/all.test.js.

If I use the same key in key.txt to both encrypt and then decrypt with rage-wasm, it works, but if it's encrypted at the command line, it desn't seem to be possible to decrypt it with rage-wasm.

In case it matters, I'm running my test in a vanilla javascript app using vite to build. I can provide a full reproduction, if needed.

Edit: I verified that keys generated with rage-wasm and data encrypted with that key can be decrypted at the command line with both age and rage.

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.