diff --git a/ticc.js b/ticc.js index 41d796d..4318b0e 100644 --- a/ticc.js +++ b/ticc.js @@ -184,7 +184,7 @@ class TicCrypto { * @return {String} * @memberof TicCrypto */ - static hash (data, { hasher = my.HASHER, salt, input = my.INPUT, output = my.OUTPUT } = {}) { + static hash_easy (data, { hasher = my.HASHER, salt, input = my.INPUT, output = my.OUTPUT } = {}) { // data can be anything, but converts to string or remains be Buffer/TypedArray/DataView if (this.is_hashable({ data })) { if (typeof data !== 'string' && !(data instanceof Buffer) && !(data instanceof DataView)) data = JSON.stringify(data) @@ -208,7 +208,7 @@ class TicCrypto { * @return {String} * @memberof TicCrypto */ - static async encrypt ({ data, tool = 'crypto', keytype = 'pwd', key, input, output, cipher } = {}) { + static async encrypt_easy ({ data, tool = 'crypto', keytype = 'pwd', key, input, output, cipher } = {}) { if (tool === 'eccrypto') { // data 应当是 utf8 的字符串。key 必须是 pubkey // eccrypto 能用 Uint8Array 和 Buffer @@ -248,7 +248,7 @@ class TicCrypto { * @return {String} * @memberof TicCrypto */ - static async decrypt ({ data = {}, tool = 'crypto', keytype = 'pwd', key, input, output, cipher } = {}) { + static async decrypt_easy ({ data = {}, tool = 'crypto', keytype = 'pwd', key, input, output, cipher } = {}) { // data 应当是 encrypt 输出的数据类型 if (tool === 'eccrypto') { try { @@ -297,7 +297,7 @@ class TicCrypto { * @return {String} * @memberof TicCrypto */ - static async sign ({ data, seckey, tool = 'crypto', hasher }) { + static async sign_easy ({ data, seckey, tool = 'crypto', hasher }) { // data can be string or buffer or object, results are the same if (this.is_hashable({ data }) && this.is_seckey(seckey)) { if (tool === 'nacl' && seckey.length === 128) { @@ -334,7 +334,7 @@ class TicCrypto { * @return {Boolean} * @memberof TicCrypto */ - static async verify ({ data, signature, pubkey, tool = 'crypto', hasher }) { + static async verify_easy ({ data, signature, pubkey, tool = 'crypto', hasher }) { // data could be anything, but converts to string or remains be Buffer/TypedArray/DataView if (this.is_hashable({ data }) && this.is_signature(signature) && this.is_pubkey({ pubkey })) { if ('nacl' === tool && signature.length === 128) { @@ -905,10 +905,10 @@ class TicCrypto { * @return {*} * @memberof TicCrypto */ - static randomize_keypair ({ tool, purpose } = {}) { + static randomize_keypair ({ tool, purpose = 'sign' } = {}) { let kp if (tool === 'nacl') { - if (purpose === 'encrypt') { + if (purpose === 'secret') { kp = nacl.box.keyPair() } else { kp = nacl.sign.keyPair()