How to use the HmacMD5 function from crypto-js

Find comprehensive JavaScript crypto-js.HmacMD5 code examples handpicked from public code repositorys.

328
329
330
331
332
333
334
335
336
var CryptoJS = require('crypto-js')

function HMACEncrypt() {
    var text = "I love python!"
    var key = "secret"
    return CryptoJS.HmacMD5(text, key).toString();
    // return CryptoJS.HmacSHA1(text, key).toString();
    // return CryptoJS.HmacSHA256(text, key).toString();
}
fork icon34
star icon57
watch icon0

+ 7 other calls in file

129
130
131
132
133
134
135
136
137
138
const msg_hex = ba2hex(msg)
const key_words = CryptoJS.enc.Hex.parse(key_hex)
const msg_words = CryptoJS.enc.Hex.parse(msg_hex)
let hash;
if (algo === 'md5') {
  hash = CryptoJS.HmacMD5(msg_words, key_words)
  return wa2ba(hash.words)
} else if (algo === 'sha1') {
  hash = CryptoJS.HmacSHA1(msg_words, key_words)
  return wa2ba(hash.words)
fork icon21
star icon30
watch icon9

+ 3 other calls in file

4
5
6
7
8
9
10
11
12

var auth_uri = 'https://sandbox-authservice.priaid.ch/login';

//function to get hashed string 
const genHashString = () => {
                const hash = CryptoJS.HmacMD5(auth_uri,config.SECRET_KEY);
                const hashString = hash.toString(CryptoJS.enc.Base64);
                return hashString;
}
fork icon1
star icon4
watch icon1

15
16
17
18
19
20
21
22
23
24
    const paramsArray = [];
    const ksortValue = ksort(value);
    Object.keys(ksortValue).forEach(key => paramsArray.push(key + '=' + ksortValue[key]));
    const str = paramsArray.join('&');
    console.log(str, key)
    const md5Value = crypto.HmacMD5(str, key).toString();
    return md5Value;
}

function environment () {
fork icon0
star icon2
watch icon1

77
78
79
80
81
82
83
84
85
86
},
ripemd160() {
  return CryptoJS.RIPEMD160(this.text).toString();
},
hmacmd5() {
  return CryptoJS.HmacMD5(this.text, this.serect).toString();
},
hmacsha1() {
  return CryptoJS.HmacSHA1(this.text, this.serect).toString();
},
fork icon0
star icon1
watch icon1

+ 17 other calls in file

1
2
3
4
5
6
7
8
9
var CryptoJS = require('crypto-js')

function HMACEncrypt() {
    var text = "I love python!"
    var key = "secret"
    return CryptoJS.HmacMD5(text, key).toString(); // 9c503a1f852edcc3526ea56976c38edf
    // return CryptoJS.HmacSHA1(text, key).toString();
    // return CryptoJS.HmacSHA256(text, key).toString();
}
fork icon0
star icon1
watch icon2

77
78
79
80
81
82
83
84
85
86
};

/* MD5 hashing */
exports.MD5 = function(text, key) {
    try {
        return typeof key !== undefined ? CryptoJS.HmacMD5(text, key) : CryptoJS.MD5(text);
    }
        catch (err) {
        throw "ERROR - utils/utilidades.js _ MD5 method";
    }
fork icon1
star icon0
watch icon2

+ 3 other calls in file

0
1
2
3
4
5
6
7
8
9
var CryptoJS = require('crypto-js')

function HMACEncrypt() {
    var text = "I love python!"
    var key = "secret111"   // 密钥文件
    // return CryptoJS.HmacMD5(text, key).toString();
    // return CryptoJS.HmacSHA1(text, key).toString();
    return CryptoJS.HmacSHA256(text, key).toString();
}
console.log(HMACEncrypt())
fork icon0
star icon0
watch icon2