加解密、编码解码Api接口

加解密、编码解码Api接口

2023年03月28日 阅读:50 字数:817 阅读时长:2 分钟

支持哈希(MD5、SHA)、UUID、加解密(AES、DES、TripleDES、Rabbit、RC4、RC4Drop)、编码转换(Base64、Hex、Utf8、Utf16)功能

支持哈希(MD5、SHA)、UUID、加解密(AES、DES、TripleDES、Rabbit、RC4、RC4Drop)、编码转换(Base64、Hex、Utf8、Utf16)功能

1. 哈希

1.1. MD5

MD5 是一种广泛使用的哈希函数

地址:https://api.timelessq.com/crypto/hash/md5

1.1.1. 请求参数

参数名 位置 类型 必填 说明 示例值
message query string 要处理的信息 Timeless
size query integer  返回的长度:16、32等。默认返回算法生成的全部信息 16
textCase query integer  大小写,upper:大写、lower:小写。默认返回小写  

1.1.2. 示例代码

var axios = require('axios');

var config = {
   method: 'get',
   url: 'https://api.timelessq.com/crypto/hash/md5',
   params: {
      message: 'Timeless',
      size: 16
   }
};

axios(config)
.then(function (response) {
   console.log(JSON.stringify(response.data));
})
.catch(function (error) {
   console.log(error);
});

1.1.3. 返回响应

{
    "errno": 0,
    "errmsg": "",
    "data": "a6f2b21cc7027c89"
}

1.2. SHA

SHA 哈希函数由国家安全局设计,是一个密码散列函数家族

地址:https://api.timelessq.com/crypto/hash/sha

1.2.1. 请求参数

参数名 位置 类型 必填 说明 示例值
message query string 要处理的信息 Timeless
algorithm query integer  哈希算法,1、256、512,默认256 512

1.2.2. 示例代码

var axios = require('axios');

var config = {
   method: 'get',
   url: 'https://api.timelessq.com/crypto/hash/sha',
   params: {
      message: 'Timeless',
      algorithm: 512
   }
};

axios(config)
.then(function (response) {
   console.log(JSON.stringify(response.data));
})
.catch(function (error) {
   console.log(error);
});

1.2.3. 返回响应

{
    "errno": 0,
    "errmsg": "",
    "data": "77a4a0e5a07605130bb5dac8cd1e5e842f656d6a07a8aff229a13e71c68242cd5e37de51013b84cdd273669982454b94f72d83e33137bd96a6d2bb0198d2e8ad"
}

2. UUID

UUID是通用唯一识别码,标准型式包含32个16进制数字,以连字号分为五段,形式为8-4-4-4-12的32个字符,如:550e8400-e29b-41d4-a716-446655440000。

地址:https://api.timelessq.com/crypto/hash/uuid

2.1. 请求参数

参数名 位置 类型 必填 说明 示例值
version query integer UUID版本,1:时间戳、4:随机,默认4  
count query integer  输出多少组的UUID,默认1 3
textCase query integer  大小写,upper:大写、lower:小写。默认返回小写  

2.2. 示例代码

var axios = require('axios');

var config = {
   method: 'get',
   url: 'https://api.timelessq.com/crypto/hash/uuid',
   params: {
      version: 4,
      count: 3,
      textCase: 'lower'
   }
};

axios(config)
.then(function (response) {
   console.log(JSON.stringify(response.data));
})
.catch(function (error) {
   console.log(error);
});

2.3. 返回示例

{
    "errno": 0,
    "errmsg": "",
    "data": [
        "0d936399-dcd0-4163-99dc-6e8ec66a4087",
        "af0192a4-67b4-4270-a83b-28258a81f9a2",
        "9f3370ae-c6fb-498f-a0a0-042b3ce18d09"
    ]
}

3. 加解密

加密以及解密,支持的加密算法:AES、DES、TripleDES、Rabbit、RC4、RC4Drop

地址:https://api.timelessq.com/crypto/cipher

3.1. 请求参数

参数名 位置 类型 必填 说明 示例值
message query string 加、解密的信息 相合之物
secret query string 秘钥 Timeless
algorithm query string 加密算法,AES、DES、TripleDES、Rabbit、RC4、RC4Drop AES
type query integer  0:加密、1:解密,默认0  

3.2. 示例代码

加密:

var axios = require('axios');

var config = {
   method: 'get',
   url: 'https://api.timelessq.com/crypto/cipher',
   params: { 
      'message': '相合之物',
      'secret': 'Timeless',
      'algorithm': 'AES'
   }
};

axios(config)
.then(function (response) {
   console.log(JSON.stringify(response.data));
})
.catch(function (error) {
   console.log(error);
});

解密:

var axios = require('axios');

var config = {
   method: 'get',
   url: 'https://api.timelessq.com/crypto/cipher',
   params: { 
      'message': '6a2ea53382248e8108fca693620de742',
      'secret': 'Timeless',
      'algorithm': 'AES',
      'type': 1
   }
};

axios(config)
.then(function (response) {
   console.log(JSON.stringify(response.data));
})
.catch(function (error) {
   console.log(error);
});

3.3. 返回示例

加密:

{
    "errno": 0,
    "errmsg": "",
    "data": "6a2ea53382248e8108fca693620de742"
}

加密:

{
    "errno": 0,
    "errmsg": "",
    "data": "相合之物"
}

4. 编码转换

Base64、Hex、Utf8、Utf16 编码互转

地址:https://api.timelessq.com/crypto/encoder

4.1. 请求参数

参数名 位置 类型 必填 说明 示例值
message query string 要处理的信息 Timeless
algorithm query string 处理算法,Base64、Hex、Utf8、Utf16 Base64
type query integer  0:编码、1:解码,默认0编码  

4.2. 示例代码

编码

var axios = require('axios');

var config = {
   method: 'get',
   url: 'https://api.timelessq.com/crypto/encoder',
   params: { 
      'message': 'Timeless',
      'algorithm': 'Base64'
   }
};

axios(config)
.then(function (response) {
   console.log(JSON.stringify(response.data));
})
.catch(function (error) {
   console.log(error);
});

解码

var axios = require('axios');

var config = {
   method: 'get',
   url: 'https://api.timelessq.com/crypto/encoder',
   params: { 
      'message': 'VGltZWxlc3M=',
      'algorithm': 'Base64',
      'type': 1
   }
};

axios(config)
.then(function (response) {
   console.log(JSON.stringify(response.data));
})
.catch(function (error) {
   console.log(error);
});

4.3. 返回示例

编码

{
    "errno": 0,
    "errmsg": "",
    "data": "VGltZWxlc3M="
}

解码

{
    "errno": 0,
    "errmsg": "",
    "data": "Timeless"
}

推荐阅读

恰饭区

评论区 (0)

0/500

还没有评论,快来抢第一吧