Fix hashCode function for Entry

This commit is contained in:
Jakob Nixdorf 2017-07-14 20:01:26 +02:00
parent 3543cc9685
commit ea2b18bde9
No known key found for this signature in database
GPG key ID: BE99BF86574A7DBC

View file

@ -44,10 +44,10 @@ public class Entry {
private static final String JSON_PERIOD = "period";
private static final String JSON_TYPE = "type";
private OTPType type;
private OTPType type = OTPType.TOTP;
private byte[] secret;
private String label;
private int period;
private int period = TOTPHelper.TOTP_DEFAULT_PERIOD;
private String currentOTP;
private long last_update = 0;
@ -190,8 +190,12 @@ public class Entry {
@Override
public int hashCode() {
int result = secret != null ? Arrays.hashCode(secret) : 0;
result = 31 * result + (label != null ? label.hashCode() : 0);
return result;
int hash = 1;
hash = hash + (secret == null ? 0 : Arrays.hashCode(secret));
hash = hash + 13 * (label == null ? 0 : label.hashCode());
hash = hash + 17 * type.hashCode();
hash = hash + 31 * period;
return hash;
}
}