cordova-android/framework/assets/js/crypto.js

41 lines
1.0 KiB
JavaScript
Raw Normal View History

/*
* PhoneGap is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
*
* Copyright (c) 2005-2010, Nitobi Software Inc.
* Copyright (c) 2010, IBM Corporation
*/
// TODO: Needs to be commented
2010-02-25 08:19:01 +08:00
if (!PhoneGap.hasResource("crypto")) {
PhoneGap.addResource("crypto");
var Crypto = function() {
};
2010-02-25 08:19:01 +08:00
Crypto.prototype.encrypt = function(seed, string, callback) {
this.encryptWin = callback;
PhoneGap.exec(null, null, "Crypto", "encrypt", [seed, string]);
};
2010-02-25 08:19:01 +08:00
Crypto.prototype.decrypt = function(seed, string, callback) {
this.decryptWin = callback;
PhoneGap.exec(null, null, "Crypto", "decrypt", [seed, string]);
};
2010-02-25 08:19:01 +08:00
Crypto.prototype.gotCryptedString = function(string) {
this.encryptWin(string);
};
Crypto.prototype.getPlainString = function(string) {
this.decryptWin(string);
};
2010-02-25 08:19:01 +08:00
PhoneGap.addConstructor(function() {
if (typeof navigator.Crypto === "undefined") {
navigator.Crypto = new Crypto();
}
2010-02-25 08:19:01 +08:00
});
};