web stats
CryptoJS - Page 2 - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #11  
Old 10-14-2014, 06:13 AM
kpatel kpatel is offline
What's HL7?
 
Join Date: Oct 2014
Posts: 5
kpatel is on a distinguished road
Default

I download the "aes.js" from http://code.google.com/p/crypto-js/s...rollups/?r=636, do I copy&paste the contents into function field of the code template but it's not working can you please explain me how to do it.
it's giving error : TypeError: Cannot call method "decrypt" of undefined

Last edited by kpatel; 10-14-2014 at 06:17 AM.
Reply With Quote
  #12  
Old 10-14-2014, 06:16 AM
skekasaurus skekasaurus is offline
OBX.3 Kenobi
 
Join Date: Dec 2013
Posts: 145
skekasaurus is on a distinguished road
Default

Copy the CryptoJS source code, and paste it into a new code template. The type would be function, and I use global as my context.
__________________
Mirth Connect v3.2.2
Java 8
SQL Server 2005
Reply With Quote
  #13  
Old 10-14-2014, 06:23 AM
skekasaurus skekasaurus is offline
OBX.3 Kenobi
 
Join Date: Dec 2013
Posts: 145
skekasaurus is on a distinguished road
Default

Quote:
Originally Posted by kpatel View Post
I download the "aes.js" from http://code.google.com/p/crypto-js/s...rollups/?r=636, do I copy&paste the contents into function field of the code template but it's not working can you please explain me how to do it.
it's giving error : TypeError: Cannot call method "decrypt" of undefined
Can you show how you're trying to use it in your code and where (in preprocessor, transformer, etc.)?
__________________
Mirth Connect v3.2.2
Java 8
SQL Server 2005
Reply With Quote
  #14  
Old 10-14-2014, 06:39 AM
kpatel kpatel is offline
What's HL7?
 
Join Date: Oct 2014
Posts: 5
kpatel is on a distinguished road
Default

i did same but it's not working.

for Example :

function function_name() {

AES SCRIPT PEST HERE

}
Reply With Quote
  #15  
Old 10-14-2014, 06:41 AM
skekasaurus skekasaurus is offline
OBX.3 Kenobi
 
Join Date: Dec 2013
Posts: 145
skekasaurus is on a distinguished road
Default

Quote:
Originally Posted by kpatel View Post
i did same but it's not working.

for Example :

function function_name() {

AES SCRIPT PEST HERE

}
You don't need the function declaration. The contents will only be the source of the AES.js file.
__________________
Mirth Connect v3.2.2
Java 8
SQL Server 2005
Reply With Quote
  #16  
Old 10-14-2014, 06:43 AM
kpatel kpatel is offline
What's HL7?
 
Join Date: Oct 2014
Posts: 5
kpatel is on a distinguished road
Default

// Read Encryption from File
getPropertyGlobal('Test/TestFile','TestFile','Text');
var encrypted = String(globalMap.get('TestFile.Text'));

// Read key From File
getPropertyGlobal('Test/key/key','key','key');
var key = String(globalMap.get('key.key'));

// Read iv From File
getPropertyGlobal('Test/key/key','key','iv');
var iv = String(globalMap.get('key.iv'));


//Decryption
var decrypted = CryptoJS.AES.decrypt(encrypted, key, {
keySize: 128 / 8,
iv: iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
});

logger.info('Decrypted Text : ' + decrypted.toString(CryptoJS.enc.Utf8)); // Read Text From Decryption
Reply With Quote
  #17  
Old 10-14-2014, 06:46 AM
skekasaurus skekasaurus is offline
OBX.3 Kenobi
 
Join Date: Dec 2013
Posts: 145
skekasaurus is on a distinguished road
Default

Quote:
Originally Posted by kpatel View Post
// Read Encryption from File
getPropertyGlobal('Test/TestFile','TestFile','Text');
var encrypted = String(globalMap.get('TestFile.Text'));

// Read key From File
getPropertyGlobal('Test/key/key','key','key');
var key = String(globalMap.get('key.key'));

// Read iv From File
getPropertyGlobal('Test/key/key','key','iv');
var iv = String(globalMap.get('key.iv'));


//Decryption
var decrypted = CryptoJS.AES.decrypt(encrypted, key, {
keySize: 128 / 8,
iv: iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
});

logger.info('Decrypted Text : ' + decrypted.toString(CryptoJS.enc.Utf8)); // Read Text From Decryption
is that a question?
__________________
Mirth Connect v3.2.2
Java 8
SQL Server 2005
Reply With Quote
  #18  
Old 10-14-2014, 06:48 AM
kpatel kpatel is offline
What's HL7?
 
Join Date: Oct 2014
Posts: 5
kpatel is on a distinguished road
Default

i take out function declaration and paste aes.js content but it still giving same error :

//Decryption785: var decrypted = CryptoJS.AES.decrypt(encrypted, key, {786: keySize: 128 / 8,787: iv: iv,788: mode: CryptoJS.mode.CBC,789: padding: CryptoJS.pad.Pkcs7LINE NUMBER:
785DETAILS:
ReferenceError: "CryptoJS" is not defined.
at Deploy:785 (doScript)
Reply With Quote
  #19  
Old 10-14-2014, 06:53 AM
skekasaurus skekasaurus is offline
OBX.3 Kenobi
 
Join Date: Dec 2013
Posts: 145
skekasaurus is on a distinguished road
Default

Quote:
Originally Posted by kpatel View Post
i take out function declaration and paste aes.js content but it still giving same error :

//Decryption785: var decrypted = CryptoJS.AES.decrypt(encrypted, key, {786: keySize: 128 / 8,787: iv: iv,788: mode: CryptoJS.mode.CBC,789: padding: CryptoJS.pad.Pkcs7LINE NUMBER:
785DETAILS:
ReferenceError: "CryptoJS" is not defined.
at Deploy:785 (doScript)


This is how I use it:

Code:
var decryptedPass = CryptoJS.AES.decrypt(password, key,...etc)
Attached Images
File Type: jpg 000021.jpg (41.2 KB, 211 views)
__________________
Mirth Connect v3.2.2
Java 8
SQL Server 2005
Reply With Quote
  #20  
Old 10-14-2014, 07:01 AM
kpatel kpatel is offline
What's HL7?
 
Join Date: Oct 2014
Posts: 5
kpatel is on a distinguished road
Default

i got it. Thank you
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 01:02 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation