1.0.1 • Published 7 years ago
kofo-utils v1.0.1
kofo-utils
Kofo utils
Install
npm install kofo-utils --saveTest
npm testAPI
createKofoId() Create Kofo pubkey and secret
//Create kofoId, pubkey, secret const obj = Utils.createKofoId(); return: { kofoId: 'KOFOjNZSVTtXqSKtQNszQki6nHjt2F67GxqDeTqyBfM9nTuk', pubkey: '027590ba33bf9ec4afe5848b12faec5d5e7bc194f30f3ca29f121675d02b92d223', secret: 'dafd1ae95b8bb22617a05fcc022f65c53adf6ef26ece15ab69374538533033a6' }createPublicKey(secret
<String>) Create pubkey by kofo secretUtils.createPublicKey(kofo.secret);createKofoIdBySecret(secret
<String>) Create kofoId by kofo secretUtils.createKofoIdBySecret(kofo.secret);createKofoIdByPubKey(publicKey
<String>) Create kofoId by kofo pubkeyUtils.createKofoIdByPubKey(kofo.pubkey);sign(secret
<String>, data<any>) Sign the data use kofo secret//Use secret for elliptic curve signature const signed = Utils.sign(kofo.secret, 'Hello world!');verifyWithKofoId(kofoId
<String>, signature<String>, data<any>) Verify signature with kofo id//Verify signature with kofo id Utils.verifyWithKofoId(kofo.kofoId, signed, 'Hello world!')verifyWithPubKey(pubkey
<String>, signature<String>, data<any>) Verify signature with kofo pubkey//Verify signature with public key Utils.verifyWithPubKey(kofo.pubkey, signed, 'Hello world!');sha256(data
<any>) Sha256 encryptionUtils.sha256('message')sha256Twice(data
<any>) Sha256 twice encryptionUtils.sha256Twice('message')createPreImage() Generate random string of length 124
Utils.createPreImage()createHValue() Sha256 twice encryption preImage create hValue
const preImage = Utils.createPreImage(); Utils.createHValue(preImage)encrypt(data
<any>, secret<String>) Encrypts a message.Utils.encrypt('data','pwd')decrypt(data
<any>, secret<String>) Decrypts serialized ciphertext.const encryptedData = Utils.encrypt('data','pwd') Utils.decrypt(encryptedData,'pwd')
1.0.1
7 years ago