website logo
WebsiteTry DashboardContact Sales
⌘K
πŸ‘‹Welcome to mintBlue!
❓Why Use mintBlue?
🧧mintBlue Products
⛓️Enterprise Bitcoin
πŸš€Introduction
πŸ‘‰mintBlue Quick Start Guide
πŸ”—Setting up Zapier & mintBlue
πŸŽ‡mintBlue SDK
πŸ‘‰SDK Quick Start Guide
πŸ—οΈSDK Encryption
πŸ“©Envelopes
πŸ–₯️SDK Server
πŸ“SDK Scripts
πŸ“–mintBlue API
⏹️Blockchain API
πŸ“‘Token API
πŸ–₯️mintBlue Console
πŸ‘‚Event Listeners
πŸ†Examples of Building with mintBlue
πŸ”‘password manager
πŸ“ƒNotary Express App
Docs powered byΒ archbeeΒ 

password manager

1min

This example assumes you have already installed the SDK and generated SDK keys as explained in ο»ΏmintBlue Quick Start Guide

Build a rudimentary blockchain-based password manager in a few lines of code! The code below stores and retrieves encrypted, immutable passwords on the blockchain.

Replace your SDK key and project id and try it out!

Node.js
|
const { Mintblue } = require('mintblue');

// show the user how to use the app
if(process.argv.length < 4 || !['get', 'add'].includes(process.argv[2])) {
    console.log('Usage:');
    console.log('Add/Update password: node pwmanage.js add [name] [password]');
    console.log('Retrieve password: node pwmanage.js get [name]');
    process.exit();
}

const command = process.argv[2];
const name = process.argv[3];
let pw = process.argv[4];

(async () => {
	let client = await Mintblue.create({token: '[YOUR_SDK_KEY]'});
	let project = '[YOUR_PROJECT_ID]';

	if(command === 'add') {
        // store key value object with name and password encrypted on blockchain
	    const { txid } = await client.createTransaction({
			project_id: project, 
			outputs: [{
				type: 'data', 
				value: { name, pw },
				encrypt: true
			}]
		});
        // show result to user
		console.log(`Password stored encrypted in transaction with id ${txid}`);
	} else if (command === 'get') {
        // get all of this project's transactions
		const txs = await client.listTransactions(project);
        // find record for requested name and decrypt it
		for(let i = 0; i < txs.length; i++) {
			const payload = await client.getTransaction(txs[i].txid);
			if(payload[0].value.name === name) {
                // Show decrypted password to user
				console.log(`Password for ${name} is ${payload[0].value.pw}`);
				process.exit();
			}
		}
		console.log(`Password not found for ${name}`);
	}

})();

ο»Ώ

ο»Ώ

Updated 08 Jul 2022
Did this page help you?
Yes
No
PREVIOUS
Actions
NEXT
Notary Express App
Docs powered byΒ archbeeΒ