Firstly create a method called sha1(String password). Here pass the password as a string as a parameter.
String sha1(String input) throws NoSuchAlgorithmException {
MessageDigest mDigest = MessageDigest.getInstance("SHA1");
byte[] result = mDigest.digest(input.getBytes());
StringBuffer sb = new StringBuffer();
for (int i = 0; i < result.length; i++) {
sb.append(Integer.toString((result[i] & 0xff) + 0x100, 16)
.substring(1));
}
return sb.toString();
}
Now just get the input from user and store it using this method into database
String shapassword = sha1(masterPassword.getText().toString().trim());
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.