List of usage examples for android.util Base64 NO_WRAP
int NO_WRAP
To view the source code for android.util Base64 NO_WRAP.
Click Source Link
From source file:Main.java
public static String largeFileSha1(File file) { InputStream inputStream = null; try {/*w w w. j a v a2s .com*/ MessageDigest gsha1 = MessageDigest.getInstance("SHA1"); MessageDigest sha1 = MessageDigest.getInstance("SHA1"); inputStream = new BufferedInputStream(new FileInputStream(file)); byte[] buffer = new byte[1024]; int nRead = 0; int block = 0; int count = 0; final int BLOCK_SIZE = 4 * 1024 * 1024; while ((nRead = inputStream.read(buffer)) != -1) { count += nRead; sha1.update(buffer, 0, nRead); if (BLOCK_SIZE == count) { gsha1.update(sha1.digest()); sha1 = MessageDigest.getInstance("SHA1"); block++; count = 0; } } if (count != 0) { gsha1.update(sha1.digest()); block++; } byte[] digest = gsha1.digest(); byte[] blockBytes = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(block).array(); byte[] result = ByteBuffer.allocate(4 + digest.length).put(blockBytes, 0, blockBytes.length) .put(digest, 0, digest.length).array(); return Base64.encodeToString(result, Base64.URL_SAFE | Base64.NO_WRAP); } catch (Exception e) { e.printStackTrace(); } finally { if (inputStream != null) { try { inputStream.close(); } catch (IOException e) { e.printStackTrace(); } } } return null; }
From source file:fr.bde_eseo.eseomega.events.tickets.AsyncEventEmail.java
public AsyncEventEmail(Context context, String email, AppCompatActivity backActivity, UserProfile userProfile, int idcmd) { this.context = context; this.email = email; this.backActivity = backActivity; this.userProfile = userProfile; this.idcmd = idcmd; this.b64email = ""; // pre init, prevents from null.getBytes try {//w w w.j a v a2 s.c o m this.b64email = Base64.encodeToString(email.getBytes("UTF-8"), Base64.NO_WRAP); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } }
From source file:de.aw.monma.hbci.FragmentMasterPassword.java
@Override public void onClick(View v) { String password = passwordView.getText().toString().trim(); String newPassword = newPasswordView.getText().toString().trim(); if (mKey == null) { if (password.equals(newPassword)) { try { mKey = AWAESEncrypter.generateKey(password); SharedPreferences.Editor editor = prefs.edit(); String key = Base64.encodeToString(mKey, Base64.NO_WRAP); editor.putString(getString(R.string.key), key).apply(); } catch (Exception e) { //TODO Execption bearbeiten e.printStackTrace();/* w w w . ja va 2 s.com*/ } } else { passwordView.setText(null); passwordView.requestFocus(); newPasswordView.setText(null); newPasswordView.setError(getString(R.string.passwordNichtIdentischError)); return; } } if (AWAESEncrypter.checkPassword(password, mKey)) { dismiss(); } else { passwordView.setText(null); passwordView.setError(getString(R.string.passwordError)); } }
From source file:com.aegiswallet.objects.SMSTransactionPojo.java
public SMSTransactionPojo(String base64EncodedJSONString) { byte[] decoded = Base64.decode(base64EncodedJSONString.getBytes(), Base64.NO_WRAP); String jsonString = new String(decoded); try {/*from w w w.j av a 2 s. c om*/ JSONObject object = new JSONObject(jsonString); this.phoneNumber = object.getString("number"); this.name = object.getString("name"); this.amount = new BigInteger(object.getString("amount")); this.btcAddress = object.getString("address"); this.timestamp = new Long(object.getString("timestamp")).longValue(); this.status = new Integer(object.getString("status")).intValue(); this.tag = object.getString("tag"); } catch (JSONException e) { Log.d(TAG, e.getMessage()); } }
From source file:com.parse.ParseEncoder.java
public Object encode(Object object) { try {//from w w w . j a va 2s . c o m if (object instanceof ParseObject) { return encodeRelatedObject((ParseObject) object); } // TODO(grantland): Remove once we disallow mutable nested queries t6941155 if (object instanceof ParseQuery.State.Builder<?>) { ParseQuery.State.Builder<?> builder = (ParseQuery.State.Builder<?>) object; return encode(builder.build()); } if (object instanceof ParseQuery.State<?>) { ParseQuery.State<?> state = (ParseQuery.State<?>) object; return state.toJSON(this); } if (object instanceof Date) { return encodeDate((Date) object); } if (object instanceof byte[]) { JSONObject json = new JSONObject(); json.put("__type", "Bytes"); json.put("base64", Base64.encodeToString((byte[]) object, Base64.NO_WRAP)); return json; } if (object instanceof ParseFile) { return ((ParseFile) object).encode(); } if (object instanceof ParseGeoPoint) { ParseGeoPoint point = (ParseGeoPoint) object; JSONObject json = new JSONObject(); json.put("__type", "GeoPoint"); json.put("latitude", point.getLatitude()); json.put("longitude", point.getLongitude()); return json; } if (object instanceof ParseACL) { ParseACL acl = (ParseACL) object; return acl.toJSONObject(this); } if (object instanceof Map) { @SuppressWarnings("unchecked") Map<String, Object> map = (Map<String, Object>) object; JSONObject json = new JSONObject(); for (Map.Entry<String, Object> pair : map.entrySet()) { json.put(pair.getKey(), encode(pair.getValue())); } return json; } if (object instanceof Collection) { JSONArray array = new JSONArray(); for (Object item : (Collection<?>) object) { array.put(encode(item)); } return array; } if (object instanceof ParseRelation) { ParseRelation<?> relation = (ParseRelation<?>) object; return relation.encodeToJSON(this); } if (object instanceof ParseFieldOperation) { return ((ParseFieldOperation) object).encode(this); } if (object instanceof ParseQuery.RelationConstraint) { return ((ParseQuery.RelationConstraint) object).encode(this); } if (object == null) { return JSONObject.NULL; } } catch (JSONException e) { throw new RuntimeException(e); } // String, Number, Boolean, if (isValidType(object)) { return object; } throw new IllegalArgumentException("invalid type for ParseObject: " + object.getClass().toString()); }
From source file:de.audioattack.yacy32c3search.activity.SettingsDialog.java
private static void store(final Context context, final String key, final String value) { final SharedPreferences.Editor editor = context.getSharedPreferences("settings", Context.MODE_PRIVATE) .edit();/* w w w .ja v a2s . c om*/ editor.putString(key, Base64.encodeToString(value.getBytes(), Base64.NO_WRAP)); editor.commit(); }
From source file:eu.codeplumbers.cosi.api.tasks.DeleteDocumentTask.java
public DeleteDocumentTask(String remoteId, Activity activity) { this.activity = activity; this.remoteId = remoteId; result = "";/* ww w. j a v a 2 s. c o m*/ Device device = Device.registeredDevice(); // cozy register device url this.url = device.getUrl() + "/ds-api/data/"; // concatenate username and password with colon for authentication final String credentials = device.getLogin() + ":" + device.getPassword(); authHeader = "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP); dialog = new ProgressDialog(activity); dialog.setCancelable(false); dialog.setMessage("Please wait"); dialog.setIndeterminate(true); dialog.show(); }
From source file:eu.codeplumbers.cosi.api.tasks.RegisterDeviceTask.java
public RegisterDeviceTask(String url, String password, String deviceString, ConnectFragment connectFragment) { this.connectFragment = connectFragment; this.deviceString = deviceString; resultDevice = null;/*from w w w . ja v a 2 s. c o m*/ // cozy register device url this.url = url + "/device/"; this.password = password; // concatenate username and password with colon for authentication final String credentials = "owner" + ":" + password; authHeader = "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP); dialog = new ProgressDialog(connectFragment.getActivity()); dialog.setCancelable(false); dialog.setMessage("Please wait"); dialog.setIndeterminate(true); dialog.show(); }
From source file:eu.codeplumbers.cosi.api.tasks.CheckDesignDocumentsTask.java
public CheckDesignDocumentsTask(Fragment connectFragment) { this.connectFragment = connectFragment; Device device = Device.registeredDevice(); // cozy register device url this.url = device.getUrl() + "/ds-api/request/???/"; // concatenate username and password with colon for authentication final String credentials = device.getLogin() + ":" + device.getPassword(); authHeader = "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP); dialog = new ProgressDialog(connectFragment.getActivity()); dialog.setCancelable(false);//from w w w. j a v a2s.c om dialog.setMessage("Please wait"); dialog.setIndeterminate(true); dialog.show(); }
From source file:eu.codeplumbers.cosi.api.tasks.UnregisterDeviceTask.java
public UnregisterDeviceTask(AboutFragment aboutFragment, String password) { this.aboutFragment = aboutFragment; resultDevice = null;//from w w w.j av a 2s. com Device device = Device.registeredDevice(); // cozy register device url this.url = device.getUrl() + "/device/"; // concatenate username and password with colon for authentication final String credentials = "owner" + ":" + password; authHeader = "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP); dialog = new ProgressDialog(aboutFragment.getActivity()); dialog.setCancelable(false); dialog.setMessage("Please wait"); dialog.setIndeterminate(true); dialog.show(); }