mirror of
https://github.com/usebruno/bruno.git
synced 2024-12-13 02:01:01 +01:00
753a576c3c
Safe Mode Sandbox using QuickJS Co-authored-by: Anoop M D <anoop.md1421@gmail.com> Co-authored-by: lohit <lohit.jiddimani@gmail.com>
34 lines
674 B
Plaintext
34 lines
674 B
Plaintext
meta {
|
|
name: crypto-js-pre-request-script
|
|
type: http
|
|
seq: 1
|
|
}
|
|
|
|
get {
|
|
url: {{host}}/ping
|
|
body: none
|
|
auth: none
|
|
}
|
|
|
|
script:pre-request {
|
|
var CryptoJS = require("crypto-js");
|
|
|
|
// Encrypt
|
|
var ciphertext = CryptoJS.AES.encrypt('my message', 'secret key 123').toString();
|
|
|
|
// Decrypt
|
|
var bytes = CryptoJS.AES.decrypt(ciphertext, 'secret key 123');
|
|
var originalText = bytes.toString(CryptoJS.enc.Utf8);
|
|
|
|
bru.setVar('crypto-test-message', originalText);
|
|
}
|
|
|
|
tests {
|
|
test("crypto message", function() {
|
|
const data = bru.getVar('crypto-test-message');
|
|
bru.setVar('crypto-test-message', null);
|
|
expect(data).to.eql('my message');
|
|
});
|
|
|
|
}
|