Caution
Deprecated Repository. This project is not in use anymore and will not be updated in case of a security breach or insecure cryptographic practice.
The standard library for encryption and decryption of Capybara. (name refers to Daniel J. Bernstein)
npm install @capybara-social/daniel
yarn add @capybara-social/daniel
pnpm add @capybara-social/daniel
const { KeyPair } = require("@capybara-social/daniel");
import { KeyPair } from "@capybara-social/daniel"
Capybara uses a hybrid encryption system between ECC(with Curve25519) and AES256-CBC
Firstly, we have to create a pair of keys, which we will use to encrypt and decrypt user's private info
const myKeys = new KeyPair();
//If you want to create a pair from an imported private key you may use it like this
const importedKeys =new KeyPair("myVerySecretKey"); //Obviously change the "myVerySecretKey" with the imported private key
This is the function you have to use to encrypt the private information of the user (Such as birthday, email, etc.)[WARNING: DO NOT ENCRYPT THE PASSWORD!]
const myKeys = new KeyPair();
const myInfo = "This text is going to be encrypted!";
let encrypted = await myKeys.encrypt(myInfo); // => this returns the encrypted text
//Once encrypted you can send this info to the server
This is the function you have to use to decrypt the private information of the user. The decrypted info can NOT be saved anywhere.
let decrypted = await myKeys.decrypt(encrypted) // => this returns the decrypted text or throw an error
This function will encrypt the private key with a password(the user's password).
const userPassword = "Really really secret password!";
let encryptedKey = await myKeys.encryptKey(userPassword);
For this you will have to import another function which will decrypt the encrypted private key [WARNING: DO NOT SAVE THE DECRYPTED PRIVATE KEY!]
const {decryptKey} = require("@capybara-social/daniel");
import {decryptKey} from "@capybara-social/daniel"
const encryptedPrivateKey = "ThisIsMyEncryptedPrivateKey!";
const password = "CapybaraIsSexy123";
let decryptedKey = await decryptKey(encryptedPrivateKey, password);
For this you will have to import 2 function
const {encryptWithPassword, decryptWithPassword} = require("@capybara-social/daniel");
import {encryptWithPassword, decryptWithPassword} from "@capybara-social/daniel"
const content = "Omg I don't want anyone to see this!";
const password = "CapybaraIsSexy123";
let encrypted = await encryptWithPassword(content, password);
const password = "CapybaraIsSexy123";
let decrypted = await decryptWithPassword(encrypted, password);
- elliptic - Fast elliptic-curve cryptography in a plain javascript implementation.
- node-forge - A native implementation of TLS (and various other cryptographic tools) in JavaScript.
This project is licensed under Attribution-ShareAlike 4.0 International
This means you have permission to:
- Share - copy and redistribute the material in any medium or format
- Adapt - remix, transform, and build upon the material for any purpose, even commercially.
Under the following terms:
- Attribution - You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- ShareAlike - If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
For more information, you may check this two sites:
Ok so it looks like you've read all this doc. Heres a photo of a kitten i found on Wikipedia specially for u <3