散列字符串不等于来自控制台C#的复制散列字符串

时间:2018-02-06 14:21:56

标签: c# encryption hash cryptography

我创建了哈希。比我在控制台上打印它。复制哈希值并将其放入代码进行比较。但它产生的不一样。

    @Override
            public void onCreate(Bundle savedInstanceState) {  
          new LoadFotos(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
          new BuildTempTable().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        }
     private class LoadFotos extends AsyncTask<Void, Void, Void> {

            Activity activity;
            List<Dokumentation> dokumentationList;
            private ProgressDialog progressDialog;

            public LoadFotos(Activity activity) {
                this.activity = activity;
                progressDialog = new ProgressDialog(activity);
            }

            @Override
            protected void onPreExecute() {
                super.onPreExecute();
                        this.progressDialog.setTitle(activity.getString("download"));
                this.progressDialog.setMessage(activity.getString(R.string.please_wait));
                this.progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                this.progressDialog.setCancelable(false);
                this.progressDialog.show();
            }

            @Override
            protected Void doInBackground(Void... voids) {
               // background process
                return null;
            }

            @Override
            protected void onPostExecute(Void aVoid) {
                super.onPostExecute(aVoid);
                if(this.progressDialog != null && this.progressDialog.isShowing() && !activity.isDestroyed()) {
                    this.progressDialog.dismiss();
                }

            }
        }

private class BuildTempTable extends AsyncTask<Void, Void, Void> {
@Override
        protected Void doInBackground(Void... voids) {
           // heavy background process
            return null;
        }
}

console

先谢谢你

1 个答案:

答案 0 :(得分:6)

哈希的结果不是UTF-8编码的文本,不应该这样对待。将其转换为十六进制或base64。例如:

string computedHashString = Convert.ToBase64String(computedHash);

从根本上说,您需要仔细处理数据。将哈希的结果转换为文本就像尝试将mp3文件加载到图片查看器中,或尝试解压缩应用压缩算法的结果。