private byte[] getDecode(String encryption_subject) throws CryptException { try { return Base64.decode(encryption_subject); } catch (Base64DecoderException e) { throw new CryptException(e); } } }
/** * Decodes Base64 content in byte array format and returns * the decoded byte array. * * @param source The Base64 encoded data * @return decoded data * @since 1.3 * @throws Base64DecoderException */ public static byte[] decode(byte[] source) throws Base64DecoderException { return decode(source, 0, source.length); }
/** * Decodes web safe Base64 content in byte array format and returns * the decoded data. * Web safe encoding uses '-' instead of '+', '_' instead of '/' * * @param source the string to decode (decoded in default encoding) * @return the decoded data */ public static byte[] decodeWebSafe(byte[] source) throws Base64DecoderException { return decodeWebSafe(source, 0, source.length); }
private String encode(String encryption_subject, Cipher crypter) throws CryptException { try { return Base64.encode(finishTransformation(crypter, encryption_subject.getBytes(CHARSET))); } catch (UnsupportedEncodingException e) { throw new CryptException(e); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.list); setListAdapter(new StyledListItemAdapter(this)); }
private String getString(String encryption_subject, Cipher crypter) throws CryptException { try { return new String(finishTransformation(crypter, getDecode(encryption_subject)), CHARSET); } catch (UnsupportedEncodingException e) { throw new CryptException(e); } }
public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { sv = new StyledItemView(mContext, mTitles[position]); } else { sv = (StyledItemView) convertView; } sv.setContent(mTitles[position]); return sv; }
@Override protected void onResume() { super.onResume(); receiver = new TabChangeReceiver(); registerReceiver(receiver, new IntentFilter("com.novoda.TAB"), null, mHandler); }
private SecretKeyFactory getSecretKeyFactory() throws CryptException { try { return SecretKeyFactory.getInstance(ALGORITHM); } catch (NoSuchAlgorithmException e) { throw new CryptException(e); } }
/** * Encodes a byte array into Base64 notation. * Equivalent to calling * {@code encodeBytes(source, 0, source.length)} * * @param source The data to convert * @since 1.4 */ public static String encode(byte[] source) { return encode(source, 0, source.length, ALPHABET, true); }
public void onClick(View v) { Intent intent = new Intent("com.novoda.TAB"); intent.putExtra("tab", 1); sendBroadcast(intent); } };
@Override protected Dialog onCreateDialog(int id) { Dialog dialog = null; switch (id) { case DIALOG_CHOOSE_VIEW_ID: dialog = getChooseViewDialog(); break; default: dialog = super.onCreateDialog(id); } return dialog; }
/** * Decodes web safe Base64 content in byte array format and returns * the decoded byte array. * Web safe encoding uses '-' instead of '+', '_' instead of '/' * * @param source the Base64 encoded data * @param off the offset of where to begin decoding * @param len the length of characters to decode * @return decoded data */ public static byte[] decodeWebSafe(byte[] source, int off, int len) throws Base64DecoderException { return decode(source, off, len, WEBSAFE_DECODABET); }
private Cipher getCipherInstance() throws CryptException { try { return Cipher.getInstance(CIPHER_TYPE); } catch (NoSuchAlgorithmException | NoSuchPaddingException e) { throw new CryptException(e); } }
/** * Encodes a byte array into web safe Base64 notation. * * @param source The data to convert * @param doPadding is {@code true} to pad result with '=' chars * if it does not fall on 3 byte boundaries */ public static String encodeWebSafe(byte[] source, boolean doPadding) { return encode(source, 0, source.length, WEBSAFE_ALPHABET, doPadding); }
public void onClick(View v) { Intent intent = new Intent("com.novoda.TAB"); intent.putExtra("tab", 0); sendBroadcast(intent); } };
/** * Decodes Base64 content in byte array format and returns * the decoded byte array. * * @param source the Base64 encoded data * @param off the offset of where to begin decoding * @param len the length of characters to decode * @return decoded data * @since 1.3 * @throws Base64DecoderException */ public static byte[] decode(byte[] source, int off, int len) throws Base64DecoderException { return decode(source, off, len, DECODABET); }
private void initialise(PBEParameterSpec ps, SecretKey k, Cipher crypter, int decryptMode) throws CryptException { try { crypter.init(decryptMode, k, ps); } catch (InvalidKeyException | InvalidAlgorithmParameterException e) { throw new CryptException(e); } }
/** * Decodes data from Base64 notation. * * @param s the string to decode (decoded in default encoding) * @return the decoded data * @since 1.4 */ public static byte[] decode(String s) throws Base64DecoderException { byte[] bytes = s.getBytes(); return decode(bytes, 0, bytes.length); }
private byte[] finishTransformation(Cipher crypter, byte[] bytes) throws CryptException { try { return crypter.doFinal(bytes); } catch (IllegalBlockSizeException | BadPaddingException e) { throw new CryptException(e); } }