Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * 检查注册码
- * @return
- */
- public Boolean checkSN() {
- String username = et_username.getText().toString();
- String password = et_password.getText().toString();
- if (username.length() == 0) {
- return false;
- }
- if (password.length() != 16) {
- return false;
- }
- try {
- MessageDigest messageDigest = MessageDigest.getInstance("MD5");
- messageDigest.digest();
- messageDigest.update(username.getBytes());
- byte[] bytes = messageDigest.digest();
- String hexstr = toHexString(bytes, "");
- StringBuilder stringBuilder = new StringBuilder();
- for (int i = 0; i < hexstr.length(); i += 2){
- stringBuilder.append(hexstr.charAt(i));
- }
- String userSN = stringBuilder.toString();
- if (!userSN.equalsIgnoreCase(password)) {
- return false;
- }
- } catch (NoSuchAlgorithmException e) {
- e.printStackTrace();
- return false;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement