문제

I have an encrypted text message and I want to decrypt it using "crypto-js" library posted on the link: http://code.google.com/p/crypto-js/

I want to decrypt using TRIPLE DES. I downloaded the library and placed "tripledes.js" under "lib" folder in my project. And I'm calling the function to decrypt in this way:

var lib_decrypt = require('tripledes');
var message = lib_decrypt.DES.decrypt(Ti.Utils.base64decode(thetext), "secretphrase");
alert(message);

I'm always getting this error: "Cannot call method 'decrypt' of undefined".

I checked up "tripledes.js" code and sincerely its a big library so i didn't find a solution for how to use this library to decrypt my text in Titanium.

Thank you in advance.

도움이 되었습니까?

해결책 2

The problem was occured because I missed to export "CryptoJS" in "tripledes.js". So when I put "exports.CryptoJS = CryptoJS;" in "tripledes.js", everything works fine because all tripledes library functions are related to the instance of "CryptoJS"

다른 팁

Maybe the error is your object have you tried to create an instance or an object of "tripledes"

 var decode = require('tripledes');
 var test = new decode();
 var message = test.DES.decrypt(Ti.Utils.base64decode(thetext), "secretphrase");

also have you checked that tripledes.js is in order with the CommonJS Modules in Titanium? https://wiki.appcelerator.org/display/guides/CommonJS+Modules+in+Titanium

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top