
Product
Reachability for Ruby Now in Beta
Reachability analysis for Ruby is now in beta, helping teams identify which vulnerabilities are truly exploitable in their applications.
alice-crypto
Advanced tools
Cryptografic message exchanging protocol based on RSA and AES.
$ npm install alice-crypto --save
const Alice = require('alice-crypto');
const alice = new Alice();
const bob = new Alice();
const secretMessage = 'Cats are cool, but dogs are better!';
// Only Bob can decipher the contents of this message.
// May be sent over insecure channels.
const cipheredMessage = alice.write(secretMessage, bob.pubkey);
const decipheredMessage = bob.read(cipheredMessage);
assert(decipheredMessage === secretMessage);
Returns a new instance of Alice.
Note: It may take a few seconds to generate the RSA keypair, which is a blocking operation. It is recommended to create the new instance as a singleton during your app's initialization routine.
rsaKeyBits Integer: Length of the RSA keypair. Default: 2048.
aesAlgorithm String: AES algorithm to pass to node's crypto.createCipheriv and crypto.createDecipheriv functions. Default: "aes256".
aesKeyBytes Integer: Length of the AES key to be randomly generated with each encryption. Default: 32.
aesIvBytes Integer: Length of the AES initialization vector to be randomly generated with each encryption. Default: 16.
The public key string to be shared between instances of Alice over insecure channels.
Returns an object that can be sent over insecure channels to the owner of pubkey. If sign is set to true, will include signature.
Returns a string containing the original message. If pubkey is present, will verify the signature of the message and throw an error if invalid.
This sample would allow two servers running instances of Alice to communicate securely over open channels.
const Alice = require('alice-crypto');
const express = require('express');
const bodyParser = require('body-parser');
const request = require('request');
const alice = new Alice();
const app = express();
app.use(bodyParser());
const thisHostname = 'alice.example.com';
const bobHostname = 'bob.example.com';
const importantMessage =
'Bob, my bank account password is 123456. Nobody else must know!';
function sendMessage (message, hostname) {
request(`http://${hostname}/pubkey`, (err, response, body) =>
const pubkey = body;
const ciphered = alice.write(message, pubkey);
request.post(`http://${hostname}/secret-message`,
{ form: { message: JSON.stringify(ciphered) } });
);
}
app.get('/pubkey', (req, res, next) => {
res.send(alice.pubkey);
}
app.post('/secret-message', (req, res, next) => {
const ciphered = JSON.parse(req.body.message);
const message = alice.read(ciphered);
console.log(message);
}
app.listen(80);
sendMessage(importantMessage, bobHostname);
MIT
FAQs
Cryptographic message exchanging protocol
We found that alice-crypto demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Reachability analysis for Ruby is now in beta, helping teams identify which vulnerabilities are truly exploitable in their applications.

Research
/Security News
Malicious npm packages use Adspect cloaking and fake CAPTCHAs to fingerprint visitors and redirect victims to crypto-themed scam sites.

Security News
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.