Skip to content

Commit

Permalink
criptografia md5 retirada.
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreRamos7 committed Oct 19, 2020
1 parent 0e52a1e commit 3910a9f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 29 deletions.
36 changes: 17 additions & 19 deletions app/src/main/java/com/cropdox/CameraActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,25 +294,23 @@ public String md5(String senha) throws NoSuchAlgorithmException {
}

private File createImageFile() throws IOException {
try { // Create an image file name
String root = Environment.getExternalStorageDirectory().toString();
File diretorio_mobile = new File(root + "/CropDox");
//String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = this.md5(email_do_usuario_logado);

//File storageDir = diretorio_mobile;
File image = new File(
diretorio_mobile, /* directory */
imageFileName + /* prefix */
".jpg" /* suffix */
);
// Save a file: path for use with ACTION_VIEW intents
currentPhotoPath = image.getAbsolutePath();
return image;
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return null;
// Create an image file name
String root = Environment.getExternalStorageDirectory().toString();
File diretorio_mobile = new File(root + "/CropDox");
//String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = email_do_usuario_logado;

//File storageDir = diretorio_mobile;
File image = new File(
diretorio_mobile, /* directory */
imageFileName + /* prefix */
".jpg" /* suffix */
);
// Save a file: path for use with ACTION_VIEW intents
currentPhotoPath = image.getAbsolutePath();
return image;


}


Expand Down
15 changes: 5 additions & 10 deletions app/src/main/java/com/cropdox/QrActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import android.widget.TextView;
import android.widget.Toast;

import com.cropdox.remote.APIUtils;

import org.json.JSONException;
import org.json.JSONObject;
import org.opencv.android.BaseLoaderCallback;
Expand Down Expand Up @@ -137,7 +139,7 @@ public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
* Envia socketid do browser ao servidor no formato JSON
* */
private void enviar_id_browser_ao_servidor(String browser_id_qr) throws JSONException {
String message = "attemptSend ANDREOID";
//String message = "attemptSend ANDREOID";
String jsonString = "{url: \"/imagem_do_servidor\", cel_id: \"" +
mSocket.id() +
"\", browser_id: \"" +
Expand All @@ -146,10 +148,10 @@ private void enviar_id_browser_ao_servidor(String browser_id_qr) throws JSONExce
email_do_usuario_logado +
"\"}";
JSONObject listasJSON = new JSONObject(jsonString);

/*
if (TextUtils.isEmpty(message)) {
return;
}
}*/
mSocket.emit("mensagem android", listasJSON);
qr_ja_reconhecido = true;
Log.v(QR_GENIAL,"listaJSON: " + listasJSON.toString());
Expand All @@ -161,10 +163,7 @@ public void mostrarResultado() {
Intent intent = new Intent(this, TransferActivity.class);
intent.putExtra("key", qr_ja_reconhecido);
startActivity(intent);

}


private Emitter.Listener onNewMessage = new Emitter.Listener() {
@Override
public void call(final Object... args) {
Expand All @@ -177,10 +176,6 @@ public void run() {
}
};

private void addMessage(String username, String message) {
text_view_descricao.setText("username: " + username + "; message: " + message);
}

private void addMessage(String mensagem) {
text_view_descricao.setText("mensagemmm: " + mensagem);
}
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/cropdox/remote/APIUtils.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.cropdox.remote;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class APIUtils {
public APIUtils() {
}
Expand All @@ -8,4 +12,10 @@ public APIUtils() {
public static FileService getFileService(){
return RetrofitClient.getClient(API_URL).create(FileService.class);
}

public static String md5(String senha) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("MD5");
BigInteger hash = new BigInteger(1, md.digest(senha.getBytes()));
return hash.toString();
}
}

0 comments on commit 3910a9f

Please sign in to comment.