mirror of https://github.com/moparisthebest/k-9
astyle
This commit is contained in:
parent
107408c0d9
commit
32b5afc702
|
@ -66,7 +66,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||||
private SearchAccount unreadAccount = null;
|
private SearchAccount unreadAccount = null;
|
||||||
private SearchAccount integratedInboxAccount = null;
|
private SearchAccount integratedInboxAccount = null;
|
||||||
private FontSizes mFontSizes = K9.getFontSizes();
|
private FontSizes mFontSizes = K9.getFontSizes();
|
||||||
|
|
||||||
private static final int ACTIVITY_REQUEST_PICK_SETTINGS_FILE = 1;
|
private static final int ACTIVITY_REQUEST_PICK_SETTINGS_FILE = 1;
|
||||||
|
|
||||||
class AccountsHandler extends Handler {
|
class AccountsHandler extends Handler {
|
||||||
|
@ -138,12 +138,11 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProgress(boolean progress)
|
public void setProgress(boolean progress) {
|
||||||
{
|
|
||||||
mHandler.progress(progress);
|
mHandler.progress(progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActivityListener mListener = new ActivityListener() {
|
ActivityListener mListener = new ActivityListener() {
|
||||||
@Override
|
@Override
|
||||||
public void informUserOfStatus() {
|
public void informUserOfStatus() {
|
||||||
|
@ -240,15 +239,14 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||||
intent.putExtra(EXTRA_STARTUP, false);
|
intent.putExtra(EXTRA_STARTUP, false);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNewIntent(Intent intent)
|
public void onNewIntent(Intent intent) {
|
||||||
{
|
|
||||||
Uri uri = intent.getData();
|
Uri uri = intent.getData();
|
||||||
Log.i(K9.LOG_TAG, "Accounts Activity got uri " + uri);
|
Log.i(K9.LOG_TAG, "Accounts Activity got uri " + uri);
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
ContentResolver contentResolver = getContentResolver();
|
ContentResolver contentResolver = getContentResolver();
|
||||||
|
|
||||||
Log.i(K9.LOG_TAG, "Accounts Activity got content of type " + contentResolver.getType(uri));
|
Log.i(K9.LOG_TAG, "Accounts Activity got content of type " + contentResolver.getType(uri));
|
||||||
|
|
||||||
String contentType = contentResolver.getType(uri);
|
String contentType = contentResolver.getType(uri);
|
||||||
|
@ -273,7 +271,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||||
Account[] accounts = Preferences.getPreferences(this).getAccounts();
|
Account[] accounts = Preferences.getPreferences(this).getAccounts();
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
boolean startup = intent.getData() == null && intent.getBooleanExtra(EXTRA_STARTUP, true);
|
boolean startup = intent.getData() == null && intent.getBooleanExtra(EXTRA_STARTUP, true);
|
||||||
onNewIntent(intent);
|
onNewIntent(intent);
|
||||||
if (startup && K9.startIntegratedInbox()) {
|
if (startup && K9.startIntegratedInbox()) {
|
||||||
onOpenAccount(integratedInboxAccount);
|
onOpenAccount(integratedInboxAccount);
|
||||||
finish();
|
finish();
|
||||||
|
@ -299,7 +297,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||||
|
|
||||||
restoreAccountStats(icicle);
|
restoreAccountStats(icicle);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -782,76 +780,61 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onImport()
|
private void onImport() {
|
||||||
{
|
|
||||||
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
|
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
|
||||||
i.addCategory(Intent.CATEGORY_OPENABLE);
|
i.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
i.setType("*/*");
|
i.setType("*/*");
|
||||||
startActivityForResult(Intent.createChooser(i, null), ACTIVITY_REQUEST_PICK_SETTINGS_FILE);
|
startActivityForResult(Intent.createChooser(i, null), ACTIVITY_REQUEST_PICK_SETTINGS_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data)
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
{
|
|
||||||
Log.i(K9.LOG_TAG, "onActivityResult requestCode = " + requestCode + ", resultCode = " + resultCode + ", data = " + data);
|
Log.i(K9.LOG_TAG, "onActivityResult requestCode = " + requestCode + ", resultCode = " + resultCode + ", data = " + data);
|
||||||
if (resultCode != RESULT_OK)
|
if (resultCode != RESULT_OK)
|
||||||
return;
|
return;
|
||||||
if (data == null)
|
if (data == null) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (requestCode)
|
switch (requestCode) {
|
||||||
{
|
case ACTIVITY_REQUEST_PICK_SETTINGS_FILE:
|
||||||
case ACTIVITY_REQUEST_PICK_SETTINGS_FILE:
|
onImport(data.getData());
|
||||||
onImport(data.getData());
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onImport(Uri uri)
|
private void onImport(Uri uri) {
|
||||||
{
|
|
||||||
Log.i(K9.LOG_TAG, "onImport importing from URI " + uri.getPath());
|
Log.i(K9.LOG_TAG, "onImport importing from URI " + uri.getPath());
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
final String fileName = uri.getPath();
|
final String fileName = uri.getPath();
|
||||||
ContentResolver resolver = getContentResolver();
|
ContentResolver resolver = getContentResolver();
|
||||||
final InputStream is = resolver.openInputStream(uri);
|
final InputStream is = resolver.openInputStream(uri);
|
||||||
|
|
||||||
PasswordEntryDialog dialog = new PasswordEntryDialog(this, getString(R.string.settings_encryption_password_prompt),
|
PasswordEntryDialog dialog = new PasswordEntryDialog(this, getString(R.string.settings_encryption_password_prompt),
|
||||||
new PasswordEntryDialog.PasswordEntryListener()
|
new PasswordEntryDialog.PasswordEntryListener() {
|
||||||
{
|
public void passwordChosen(String chosenPassword) {
|
||||||
public void passwordChosen(String chosenPassword)
|
String toastText = Accounts.this.getString(R.string.settings_importing);
|
||||||
{
|
|
||||||
String toastText = Accounts.this.getString(R.string.settings_importing );
|
|
||||||
Toast toast = Toast.makeText(Accounts.this.getApplication(), toastText, Toast.LENGTH_SHORT);
|
Toast toast = Toast.makeText(Accounts.this.getApplication(), toastText, Toast.LENGTH_SHORT);
|
||||||
toast.show();
|
toast.show();
|
||||||
mHandler.progress(true);
|
mHandler.progress(true);
|
||||||
AsyncUIProcessor.getInstance(Accounts.this.getApplication()).importSettings(is, chosenPassword, new ImportListener()
|
AsyncUIProcessor.getInstance(Accounts.this.getApplication()).importSettings(is, chosenPassword, new ImportListener() {
|
||||||
{
|
public void failure(final String message, Exception e) {
|
||||||
public void failure(final String message, Exception e)
|
Accounts.this.runOnUiThread(new Runnable() {
|
||||||
{
|
public void run() {
|
||||||
Accounts.this.runOnUiThread(new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
mHandler.progress(false);
|
mHandler.progress(false);
|
||||||
showDialog(Accounts.this, R.string.settings_import_failed_header, Accounts.this.getString(R.string.settings_import_failure, fileName, message));
|
showDialog(Accounts.this, R.string.settings_import_failed_header, Accounts.this.getString(R.string.settings_import_failure, fileName, message));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void importSuccess(final int numAccounts)
|
public void importSuccess(final int numAccounts) {
|
||||||
{
|
Accounts.this.runOnUiThread(new Runnable() {
|
||||||
Accounts.this.runOnUiThread(new Runnable()
|
public void run() {
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
mHandler.progress(false);
|
mHandler.progress(false);
|
||||||
String messageText =
|
String messageText =
|
||||||
numAccounts != 1
|
numAccounts != 1
|
||||||
? Accounts.this.getString(R.string.settings_import_success_multiple, numAccounts, fileName )
|
? Accounts.this.getString(R.string.settings_import_success_multiple, numAccounts, fileName)
|
||||||
: Accounts.this.getString(R.string.settings_import_success_single, fileName );
|
: Accounts.this.getString(R.string.settings_import_success_single, fileName);
|
||||||
showDialog(Accounts.this, R.string.settings_import_success_header, messageText);
|
showDialog(Accounts.this, R.string.settings_import_success_header, messageText);
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
@ -859,23 +842,19 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancel()
|
public void cancel() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
} catch (FileNotFoundException fnfe) {
|
||||||
catch (FileNotFoundException fnfe)
|
String toastText = Accounts.this.getString(R.string.settings_import_failure, uri.getPath(), fnfe.getMessage());
|
||||||
{
|
|
||||||
String toastText = Accounts.this.getString(R.string.settings_import_failure, uri.getPath(), fnfe.getMessage() );
|
|
||||||
Toast toast = Toast.makeText(Accounts.this.getApplication(), toastText, 1);
|
Toast toast = Toast.makeText(Accounts.this.getApplication(), toastText, 1);
|
||||||
toast.show();
|
toast.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void showDialog(final Activity activity, int headerRes, String message)
|
private static void showDialog(final Activity activity, int headerRes, String message) {
|
||||||
{
|
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||||
builder.setTitle(headerRes);
|
builder.setTitle(headerRes);
|
||||||
builder.setMessage(message);
|
builder.setMessage(message);
|
||||||
|
@ -886,7 +865,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.show();
|
builder.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,7 @@ public class ActivityListener extends MessagingListener {
|
||||||
String displayName = mLoadingFolderName;
|
String displayName = mLoadingFolderName;
|
||||||
if (K9.INBOX.equalsIgnoreCase(displayName)) {
|
if (K9.INBOX.equalsIgnoreCase(displayName)) {
|
||||||
displayName = context.getString(R.string.special_mailbox_name_inbox);
|
displayName = context.getString(R.string.special_mailbox_name_inbox);
|
||||||
}
|
} else if ((mAccount != null) && mAccount.getOutboxFolderName().equals(displayName)) {
|
||||||
else if ((mAccount != null) && mAccount.getOutboxFolderName().equals(displayName)) {
|
|
||||||
displayName = context.getString(R.string.special_mailbox_name_outbox);
|
displayName = context.getString(R.string.special_mailbox_name_outbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,7 @@ public class ExportHelper {
|
||||||
});
|
});
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
private static void showDialog(final Activity activity, int headerRes, String message)
|
private static void showDialog(final Activity activity, int headerRes, String message) {
|
||||||
{
|
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||||
builder.setTitle(headerRes);
|
builder.setTitle(headerRes);
|
||||||
builder.setMessage(message);
|
builder.setMessage(message);
|
||||||
|
@ -60,7 +59,7 @@ public class ExportHelper {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.show();
|
builder.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,12 +150,11 @@ public class FolderList extends K9ListActivity {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProgress(boolean progress)
|
public void setProgress(boolean progress) {
|
||||||
{
|
|
||||||
mHandler.progress(progress);
|
mHandler.progress(progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is responsible for reloading the list of local messages for a
|
* This class is responsible for reloading the list of local messages for a
|
||||||
* given folder, notifying the adapter that the message have been loaded and
|
* given folder, notifying the adapter that the message have been loaded and
|
||||||
|
@ -543,15 +542,15 @@ public class FolderList extends K9ListActivity {
|
||||||
onCompact(mAccount);
|
onCompact(mAccount);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case R.id.export:
|
case R.id.export:
|
||||||
onExport(mAccount);
|
onExport(mAccount);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case R.id.export_all:
|
case R.id.export_all:
|
||||||
onExport(null);
|
onExport(null);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case R.id.display_1st_class: {
|
case R.id.display_1st_class: {
|
||||||
setDisplayMode(FolderMode.FIRST_CLASS);
|
setDisplayMode(FolderMode.FIRST_CLASS);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -518,12 +518,11 @@ public class MessageList
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProgress(boolean progress)
|
public void setProgress(boolean progress) {
|
||||||
{
|
|
||||||
mHandler.progress(progress);
|
mHandler.progress(progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void actionHandleFolder(Context context, Account account, String folder) {
|
public static void actionHandleFolder(Context context, Account account, String folder) {
|
||||||
Intent intent = actionHandleFolderIntent(context, account, folder);
|
Intent intent = actionHandleFolderIntent(context, account, folder);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
@ -1405,7 +1404,7 @@ public class MessageList
|
||||||
case R.id.export: {
|
case R.id.export: {
|
||||||
onExport(mAccount);
|
onExport(mAccount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case R.id.export_all: {
|
case R.id.export_all: {
|
||||||
onExport(null);
|
onExport(null);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -943,13 +943,13 @@ public class MessageView extends K9Activity implements OnClickListener {
|
||||||
@Override
|
@Override
|
||||||
protected Dialog onCreateDialog(final int id) {
|
protected Dialog onCreateDialog(final int id) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case R.id.dialog_confirm_delete:
|
case R.id.dialog_confirm_delete:
|
||||||
return createConfirmDeleteDialog(id);
|
return createConfirmDeleteDialog(id);
|
||||||
case R.id.dialog_attachment_progress:
|
case R.id.dialog_attachment_progress:
|
||||||
ProgressDialog d = new ProgressDialog(this);
|
ProgressDialog d = new ProgressDialog(this);
|
||||||
d.setIndeterminate(true);
|
d.setIndeterminate(true);
|
||||||
d.setTitle(R.string.dialog_attachment_progress_title);
|
d.setTitle(R.string.dialog_attachment_progress_title);
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
return super.onCreateDialog(id);
|
return super.onCreateDialog(id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -853,12 +853,10 @@ public class AccountSettings extends K9PreferenceActivity {
|
||||||
|
|
||||||
// TODO: In the future the call above should be changed to only return remote folders.
|
// TODO: In the future the call above should be changed to only return remote folders.
|
||||||
// For now we just remove the Outbox folder if present.
|
// For now we just remove the Outbox folder if present.
|
||||||
Iterator<? extends Folder> iter = folders.iterator();
|
Iterator <? extends Folder > iter = folders.iterator();
|
||||||
while (iter.hasNext())
|
while (iter.hasNext()) {
|
||||||
{
|
|
||||||
Folder folder = iter.next();
|
Folder folder = iter.next();
|
||||||
if (mAccount.getOutboxFolderName().equals(folder.getName()))
|
if (mAccount.getOutboxFolderName().equals(folder.getName())) {
|
||||||
{
|
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class EncoderUtil {
|
||||||
int encodedLength = bEncodedLength(bytes);
|
int encodedLength = bEncodedLength(bytes);
|
||||||
|
|
||||||
int totalLength = prefix.length() + encodedLength
|
int totalLength = prefix.length() + encodedLength
|
||||||
+ ENC_WORD_SUFFIX.length();
|
+ ENC_WORD_SUFFIX.length();
|
||||||
if (totalLength <= ENCODED_WORD_MAX_LENGTH) {
|
if (totalLength <= ENCODED_WORD_MAX_LENGTH) {
|
||||||
return prefix + org.apache.james.mime4j.codec.EncoderUtil.encodeB(bytes) + ENC_WORD_SUFFIX;
|
return prefix + org.apache.james.mime4j.codec.EncoderUtil.encodeB(bytes) + ENC_WORD_SUFFIX;
|
||||||
} else {
|
} else {
|
||||||
|
@ -111,7 +111,7 @@ public class EncoderUtil {
|
||||||
int encodedLength = qEncodedLength(bytes);
|
int encodedLength = qEncodedLength(bytes);
|
||||||
|
|
||||||
int totalLength = prefix.length() + encodedLength
|
int totalLength = prefix.length() + encodedLength
|
||||||
+ ENC_WORD_SUFFIX.length();
|
+ ENC_WORD_SUFFIX.length();
|
||||||
if (totalLength <= ENCODED_WORD_MAX_LENGTH) {
|
if (totalLength <= ENCODED_WORD_MAX_LENGTH) {
|
||||||
return prefix + org.apache.james.mime4j.codec.EncoderUtil.encodeQ(bytes, org.apache.james.mime4j.codec.EncoderUtil.Usage.WORD_ENTITY) + ENC_WORD_SUFFIX;
|
return prefix + org.apache.james.mime4j.codec.EncoderUtil.encodeQ(bytes, org.apache.james.mime4j.codec.EncoderUtil.Usage.WORD_ENTITY) + ENC_WORD_SUFFIX;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -142,8 +142,7 @@ public class MimeHeader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCharset(String charset)
|
public void setCharset(String charset) {
|
||||||
{
|
|
||||||
mCharset = charset;
|
mCharset = charset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,25 +14,22 @@ import javax.crypto.spec.SecretKeySpec;
|
||||||
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
|
||||||
public class K9Krypto
|
public class K9Krypto {
|
||||||
{
|
|
||||||
final Base64 mBase64;
|
final Base64 mBase64;
|
||||||
final Cipher mCipher;
|
final Cipher mCipher;
|
||||||
|
|
||||||
private final static String AES = "AES";
|
private final static String AES = "AES";
|
||||||
private final static String SECURE_RANDOM_TYPE = "SHA1PRNG";
|
private final static String SECURE_RANDOM_TYPE = "SHA1PRNG";
|
||||||
|
|
||||||
public enum MODE
|
public enum MODE {
|
||||||
{
|
|
||||||
ENCRYPT(Cipher.ENCRYPT_MODE), DECRYPT(Cipher.DECRYPT_MODE);
|
ENCRYPT(Cipher.ENCRYPT_MODE), DECRYPT(Cipher.DECRYPT_MODE);
|
||||||
|
|
||||||
int mode;
|
int mode;
|
||||||
private MODE(int nMode)
|
private MODE(int nMode) {
|
||||||
{
|
|
||||||
mode = nMode;
|
mode = nMode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public K9Krypto(String key, MODE mode) throws NoSuchAlgorithmException, InvalidKeyException, NoSuchPaddingException {
|
public K9Krypto(String key, MODE mode) throws NoSuchAlgorithmException, InvalidKeyException, NoSuchPaddingException {
|
||||||
mBase64 = new Base64();
|
mBase64 = new Base64();
|
||||||
KeyGenerator keyGenerator = KeyGenerator.getInstance(AES);
|
KeyGenerator keyGenerator = KeyGenerator.getInstance(AES);
|
||||||
|
@ -43,25 +40,24 @@ public class K9Krypto
|
||||||
byte[] processedKey = secretKey.getEncoded();
|
byte[] processedKey = secretKey.getEncoded();
|
||||||
mCipher = setupCipher(mode.mode, processedKey);
|
mCipher = setupCipher(mode.mode, processedKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String encrypt(String plainText) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
|
public String encrypt(String plainText) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
|
||||||
byte[] encryptedText = mCipher.doFinal(plainText.getBytes());
|
byte[] encryptedText = mCipher.doFinal(plainText.getBytes());
|
||||||
byte[] encryptedEncodedText = mBase64.encode(encryptedText);
|
byte[] encryptedEncodedText = mBase64.encode(encryptedText);
|
||||||
return new String(encryptedEncodedText);
|
return new String(encryptedEncodedText);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String decrypt(String encryptedEncodedText) throws IllegalBlockSizeException, BadPaddingException {
|
public String decrypt(String encryptedEncodedText) throws IllegalBlockSizeException, BadPaddingException {
|
||||||
byte[] encryptedText = mBase64.decode(encryptedEncodedText.getBytes());
|
byte[] encryptedText = mBase64.decode(encryptedEncodedText.getBytes());
|
||||||
byte[] plainText = mCipher.doFinal(encryptedText);
|
byte[] plainText = mCipher.doFinal(encryptedText);
|
||||||
return new String(plainText);
|
return new String(plainText);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Cipher setupCipher(int mode, byte[] processedKey) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException
|
private Cipher setupCipher(int mode, byte[] processedKey) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException {
|
||||||
{
|
|
||||||
SecretKeySpec secretKeySpec = new SecretKeySpec(processedKey, AES);
|
SecretKeySpec secretKeySpec = new SecretKeySpec(processedKey, AES);
|
||||||
Cipher cipher = Cipher.getInstance(AES);
|
Cipher cipher = Cipher.getInstance(AES);
|
||||||
cipher.init(mode, secretKeySpec);
|
cipher.init(mode, secretKeySpec);
|
||||||
return cipher;
|
return cipher;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue