md4( input, outputEncoding )
注意
存在一个具有更好且标准 API 的模块。
crypto 模块部分实现了 WebCrypto API,支持的功能比 k6/crypto 更多。
使用 md4 对输入数据进行哈希计算。
参数 | 类型 | 描述 |
---|---|---|
input | string / ArrayBuffer | 要进行哈希计算的输入字符串或 ArrayBuffer 对象。 |
outputEncoding | string | 描述用于哈希值的编码类型。可以是 “base64”、“base64url”、“base64rawurl”、“hex” 或 “binary”。 |
返回值
类型 | 描述 |
---|---|
string / Array | 哈希摘要作为字符串(对于 “base64”、“base64url”、“base64rawurl”、“hex” 输出编码)或原始整数数组(对于 “binary” 输出编码)。 |
示例
import crypto from 'k6/crypto';
export default function () {
let hash = crypto.md4('hello world!', 'hex');
console.log(hash);
const binArray = [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 33];
hash = crypto.md4(new Uint8Array(binArray).buffer, 'hex');
console.log(hash);
}
上述脚本在执行期间应打印以下内容
INFO[0000] 3363b72840acd5f49f922fef598ee85d
INFO[0000] 3363b72840acd5f49f922fef598ee85d