第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Android 應用程序登錄屏幕 - 錯誤的變量和共享首選項比較

Android 應用程序登錄屏幕 - 錯誤的變量和共享首選項比較

慕村225694 2021-07-12 16:14:53
我正在嘗試將加密密碼存儲在我的應用程序的 SharedPreferences 中。根據日志密碼正確保存并在加密后匹配鍵入的密碼,但在比較中它們不相等。每次它運行 else 指令時。我找不到問題所在,所以我尋求幫助!順便說一句,有什么更好、更安全的密碼存儲方式,甚至是加密的?public class LoginActivity extends AppCompatActivity {    private static final String PREFERENCES_NAME = "passHashed";    private static final String PREFERENCES_TEXT_FIELD = "textField";    public EditText Password;    public TextView Info;    private String passSavedHash;    private SharedPreferences preferences;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_login);        Password = (EditText) findViewById(R.id.etPassword);        Info = (TextView) findViewById(R.id.Info);        Button loginBtn = findViewById(R.id.loginButton);        preferences = getSharedPreferences(PREFERENCES_NAME, AppCompatActivity.MODE_PRIVATE);        if(!passRead().equals("0")) {            passSavedHash = passRead();            Log.d("Password", "passHashed: " + passSavedHash);        }        else{            loginBtn.setText(R.string.set_pass);        }    }    public void onClickValidate(View view) throws Exception {        String password = Password.getText().toString();        String passHash = CipherAlgorithm.encrypt(password);        Log.d("Password", "passHashed:    " + passSavedHash);        Log.d("Password", "passSavedHash: " + passHash);        if(passRead().equals("0") && password.length() > 3) {            passSave();            Intent intent = new Intent(LoginActivity.this, MainActivity.class);            startActivity(intent);        }        else {            if (Objects.equals(passSavedHash, passHash)) {                Intent intent = new Intent(LoginActivity.this, MainActivity.class);                startActivity(intent);            } else {                Info.setText(R.string.wron_pass);            }        }        Password.setText("");    }
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 133 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號