Thanks a lot Darren! Really appreciate it!
Sorry, I canāt figure it out. Maybe @ThinhDinh might be able toā¦
No worries, Darren! Thanks for your help so much! I hope Thinh or someone else can help here!
I had another look at this and I realised that youāre missing the driver.js
file from your repo. After adding that and making a few other changes, I managed to get it to return an error message to Glide. I suspect that the function is firing before the Crypto-JS package is loaded, and so the library isnāt found. Thatās as far as Iāve gotā¦
Hmm⦠What I should I have to do?
I was also trying to add the driver.js file after looking at the docs again but still no luck!
Does I can fork you repo?
Yes, go for it.
Darren, sorry! Didnāt got it. You mean fork the repo right? In where?
Go to your repo and look for forks. You should see mine there.
Still no luck! Does anyone know the solution?
Does doing this way is possible or using a 3rd party tool is the best?
Whatās your use case for this?
Thinh, I need to get the hash value for the given message and secret key!
Like this : Hmac Generator - Code Amaze
Guys, does anyone knows the solution?
Could you use SHA-256? Thereās a native column for that.
I can but needed the SHA 1 option. I tried with MAKE too but getting a error.
Anybody?
You might have to get your hands dirty with some AppScript⦠I havenāt tried the below but I use appscript + SHA-256 in a project and it works well.
function runSHA1() {
var text = "Your text here"; // Replace with your own text
var sha1Hash = Utilities.computeDigest(Utilities.DigestAlgorithm.SHA_1, text);
var sha1HashHex = Utilities.base64Encode(sha1Hash);
Logger.log("SHA-1 Hash: " + sha1HashHex);
}
Thanks Eric! I need to get the sha1 result based on the input and secret like here : Aes - Code Amaze How to do that?
Iām out of the office at the moment but I will take a look this evening and whip something up
Here you go⦠put the Input in A2 the Secret Key in B2 and your Output will go in C2.
function computeHMACSHA1() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
// Get the input text from cell A2 and B2
var inputText = sheet.getRange("A2").getValue();
var secretKey = sheet.getRange("B2").getValue();
// Convert inputText and secretKey to Base64
var inputTextBase64 = Utilities.base64Encode(inputText);
var secretKeyBase64 = Utilities.base64Encode(secretKey);
// Convert Base64 strings back to binary
var inputBytes = Utilities.base64Decode(inputTextBase64);
var keyBytes = Utilities.base64Decode(secretKeyBase64);
// Implement HMAC-SHA1 manually
var blockSize = 64; // HMAC-SHA1 block size
if (keyBytes.length > blockSize) {
keyBytes = Utilities.computeDigest(Utilities.DigestAlgorithm.SHA_1, keyBytes);
}
while (keyBytes.length < blockSize) {
keyBytes.push(0);
}
var oKeyPad = [];
var iKeyPad = [];
for (var i = 0; i < blockSize; i++) {
oKeyPad.push(keyBytes[i] ^ 0x5C);
iKeyPad.push(keyBytes[i] ^ 0x36);
}
var innerHash = Utilities.computeDigest(Utilities.DigestAlgorithm.SHA_1, iKeyPad.concat(inputBytes));
var finalHash = Utilities.computeDigest(Utilities.DigestAlgorithm.SHA_1, oKeyPad.concat(innerHash));
// Convert the binary hash to a hexadecimal string
var hmacSha1Hex = '';
for (var i = 0; i < finalHash.length; i++) {
var byte = finalHash[i];
hmacSha1Hex += (byte & 0xFF).toString(16).padStart(2, '0'); // Format as two-digit hex without leading 0's
}
// Put the result in cell C2
sheet.getRange("C2").setValue(hmacSha1Hex);
}