Skip to content

Commit

Permalink
为默认的文件加密计算器增加校验失败的日志记录
Browse files Browse the repository at this point in the history
  • Loading branch information
xuexiangjys committed Mar 26, 2023
1 parent e5218fa commit 69b84f6
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.text.TextUtils;

import com.xuexiang.xupdate.logs.UpdateLog;
import com.xuexiang.xupdate.proxy.IFileEncryptor;
import com.xuexiang.xupdate.utils.Md5Utils;

Expand All @@ -17,8 +18,8 @@ public class DefaultFileEncryptor implements IFileEncryptor {
/**
* 加密文件
*
* @param file
* @return
* @param file 目标文件
* @return 文件的加密值
*/
@Override
public String encryptFile(File file) {
Expand All @@ -34,7 +35,15 @@ public String encryptFile(File file) {
*/
@Override
public boolean isFileValid(String encrypt, File file) {
return TextUtils.isEmpty(encrypt) || encrypt.equalsIgnoreCase(encryptFile(file));
if (TextUtils.isEmpty(encrypt)) {
return true;
}
String fileEncrypt = encryptFile(file);
boolean result = encrypt.equalsIgnoreCase(fileEncrypt);
if (!result) {
UpdateLog.d("File verification failed! Target encrypt value is: " + encrypt + ", but file encrypt value is: " + fileEncrypt);
}
return result;
}

}

0 comments on commit 69b84f6

Please sign in to comment.