2010-02-25 08:18:35 +08:00
|
|
|
package com.phonegap;
|
|
|
|
|
|
|
|
import android.webkit.WebView;
|
|
|
|
|
2010-09-04 06:24:55 +08:00
|
|
|
public class CryptoHandler extends Module {
|
2010-02-25 08:18:35 +08:00
|
|
|
|
|
|
|
WebView mView;
|
|
|
|
|
2010-09-04 06:24:55 +08:00
|
|
|
public CryptoHandler(WebView view, DroidGap gap)
|
2010-02-25 08:18:35 +08:00
|
|
|
{
|
2010-09-04 06:24:55 +08:00
|
|
|
super(view, gap);
|
2010-02-25 08:18:35 +08:00
|
|
|
mView = view;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void encrypt(String pass, String text)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
String encrypted = SimpleCrypto.encrypt(pass,text);
|
|
|
|
mView.loadUrl("javascript:Crypto.gotCryptedString('" + text + "')");
|
|
|
|
} catch (Exception e) {
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void decrypt(String pass, String text)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
String decrypted = SimpleCrypto.decrypt(pass,text);
|
|
|
|
mView.loadUrl("javascript:Crypto.gotPlainString('" + text + "')");
|
|
|
|
} catch (Exception e) {
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|