Skip to content

Instantly share code, notes, and snippets.

@alichry
Created September 18, 2021 06:11
Show Gist options
  • Save alichry/918d56c9cd87655c7b11c09cd803e319 to your computer and use it in GitHub Desktop.
Save alichry/918d56c9cd87655c7b11c09cd803e319 to your computer and use it in GitHub Desktop.
SRP client tester
#!/usr/bin/env node
const jsrp = require('jsrp');
const client = new jsrp.client();
const readline = require("readline");
const identity = process.argv[2];
const password = process.argv[3];
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
if (typeof identity === "undefined" || typeof password === "undefined") {
console.error("Nope. Need identity and password as CLI args");
process.exit(1);
}
console.log("Exporting client public key (hexA) for:");
console.log("Identity:", identity);
console.log("Password:", password);
console.log("-------------------------");
client.init({ username: identity, password: password }, function () {
console.log(client.getPublicKey());
rl.question("Please enter the server public key (hexB): ", function(serverPublicKey) {
rl.question("Please eneter the salt: ", function(salt) {
client.setSalt(salt);
client.setServerPublicKey(serverPublicKey);
rl.close();
console.log("Client proof (hexM1) is:");
console.log(client.getProof());
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment