mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-25 08:45:58 +03:00
[GH-ISSUE #3353] [feature]: support importing CryptoJS in pre-request script #1119
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#1119
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @junziqiao on GitHub (Sep 14, 2023).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/3353
Is there an existing issue for this?
Current behavior
var raw = CryptoJS.HmacSHA256(sign_string,secret_key).toString();
var words = CryptoJS.enc.Utf8.parse(raw);
use postman
``
Steps to reproduce
can not import CryptoJS in pre-request script
Environment
Production
Version
Cloud
@ifnotnithya commented on GitHub (Nov 15, 2023):
I am running into this as well.
Any plans on supporting CryptoJS
@gzgzapp commented on GitHub (Jul 8, 2024):
you can download CryptoJS file like this url (https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js)
and add the global variables ,key name CryptoJS, value is the CryptoJS flies content.
in pre-request script, you can add eval(pw.env.get("CryptoJS")) in your first script line. now CryptoJS will be imported
@kholisrag commented on GitHub (Jul 15, 2024):
worked for me
@lovelock commented on GitHub (Sep 18, 2024):
it works like a charm, thanks
@nerdbugg commented on GitHub (Jan 16, 2025):
It works, but support CryptoJS builtin will be nice for new user.
@afrocubanito commented on GitHub (Feb 24, 2025):
Hi,
Sorry for my dumb question.
After eval(pw.env.get("CryptoJS")) what will be the syntax ?
let = CryptoJS.SHA256(variable).toString() ?
@gzgzapp commented on GitHub (Feb 24, 2025):
eval(pw.env.get("CryptoJS"))
var str = "xxxxxxxxxxxxxxxxxxxxxxx",
pw = "admin";
var strSHA1 = CryptoJS.enc.Hex.stringify(CryptoJS.HmacSHA256(str, pw));
console.log(strSHA1);
You may need to search on Google about how to use the related functions of CryptoJS.
@akbarraihanm commented on GitHub (Jul 11, 2025):
Not working on me
@chyg-start commented on GitHub (Jul 16, 2025):
Hello, prompted me with 'RequestFailure: script_fail'
@waf commented on GitHub (Sep 18, 2025):
I think this will improve with the planned feature here: https://github.com/hoppscotch/hoppscotch/discussions/5221.
Until that's done, I (well, an LLM) have reimplemented HmacSHA256 / Utf8.parse and it works well for me as a pre-request script, and it passes the required crypto checks server-side. See code below. I'm sure it won't handle everything but it worked for my limited use case.
An alternate way to do this would be to use the existing Crypto/SubtleCrypto APIs that are already available in Hoppscotch prerequest scripts,, but I couldn't get them to work with the underlying faraday-cage library that Hoppscotch uses in their new scripting sandbox (ref https://github.com/AndrewBastin/faraday-cage/issues/1).
@jamesgeorge007 commented on GitHub (Nov 6, 2025):
Hi! #5090 added the ability to import ESM packages in the scripting context as part of the
Experimental scripting sandbox. You can now import crypto libraries directly:Please track the further progress in #2015.