Skip to content

Instantly share code, notes, and snippets.

View amoossssss's full-sized avatar
👨‍💻
Focusing

Amos Wu amoossssss

👨‍💻
Focusing
View GitHub Profile
@amoossssss
amoossssss / rhino_hmac.js
Last active September 15, 2023 02:51
Rhino HMAC (Pure JDK Standard Library)
function toHexString(byteArray) {
return Array.from(byteArray, function(byte) {
return ('0' + (byte & 0xFF).toString(16)).slice(-2);
}).join('')
}
function hmac(algorithm, key, message) {
var mac = javax.crypto.Mac.getInstance(algorithm);
mac.init(new javax.crypto.spec.SecretKeySpec(key, algorithm));
return mac.doFinal(message);