时光链.加密库
Go to file
2019-05-18 16:37:34 +08:00
index.js 重命名旧的默克根计算函数 2018-12-28 15:35:35 +00:00
package.json 升级uuid版本到3.3.2 2018-12-01 11:54:04 +08:00
README.md 添加 [README.md] 2019-05-18 16:37:34 +08:00

tic.crypto

时光链密码学工具库:时光链专用的密码学工具库,用来处理哈希、加解密、签名、助记词、等等。

Table of Contents

  1. Installation Guide
  2. Usage
  3. API Specification
  4. References

1. Installation Guide

在前后端软件的 package.json 的依赖清单中引入本库:

npm install git+https://git.faronear.org/tic/tic.action#latest_stable --save

2. Usage

基本用法示例:

let ticCrypto=require('tic.crypto') // 引用
let sw=ticCrypto.randomSecword() // 生成一个随机的助记词(即密语)。或者使用现成的密语。
let kp=ticCrypto.secword2keypair(sw) // 把密语转换成公私钥
let address=ticCrypto.secword2address(sw) // 把密语转换成地址

3. API Specification

函数名 参数 说明
hash (data, option={hasher:'sha256', salt, input:'utf8', output:'hex'}) 哈希算法。给input(=utf8
isHashable (data)
isHash
encrypt (data, pwd, option={ cipher:'aes-256-cfb', input:'utf8', output:'hex' })
decrypt (data, pwd, option={ cipher:'aes-256-cfb', input:'hex', output:'utf8' })
sign (data, seckey, option)
isSignature
verify (data, signature, pubkey, option)
pass2keypair
secword2keypair 密语到公私钥 { pubkey, seckey }
seckey2pubkey
secword2account 密语到账户 { address, pubkey, seckey }
secword2address 密语到地址 address
isSecword
isSeckey
isPubkey
isAddress
pubkey2address
secword2seed
randomSecword (lang) lang=[ 'CHINESE', 'ENGLISH', 'FRENCH', 'ITALIAN', 'JAPANESE', 'SPANISH' ]
randomSeckey
randomKeypair
randomString
randomNumber
randomUuid: { [Function: v4] v1
getMerkleRoot
distanceSig
compareSig
sortSigList
getString2Sign
rsaSign
rsaVerify

4. References