changed hashing method to use toString, bytearray may have proved

inconsistent
This commit is contained in:
Dave
2015-12-05 14:05:09 +02:00
parent d0e2b2d69a
commit ee92afd7da

View File

@@ -130,6 +130,7 @@ public abstract class NoUser implements Serializable {
}; };
Class<? extends NoUser> userClass = getClass(); Class<? extends NoUser> userClass = getClass();
StringBuilder toString = new StringBuilder();
while (userClass != null) { while (userClass != null) {
Field[] noHashFields = userClass.getDeclaredFields(); Field[] noHashFields = userClass.getDeclaredFields();
@@ -139,7 +140,8 @@ public abstract class NoUser implements Serializable {
for (Field field : noHashFields) { for (Field field : noHashFields) {
if (field.isAnnotationPresent(NoHash.class)) { if (field.isAnnotationPresent(NoHash.class)) {
field.setAccessible(true); field.setAccessible(true);
items.add(field.get(this)); toString.append("|");
toString.append(field.get(this).toString());
} }
} }
@@ -150,15 +152,9 @@ public abstract class NoUser implements Serializable {
} }
} }
byte[] itemBytes = toString.toString().getBytes();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(items);
byte[] itemBytes = baos.toByteArray();
return NoUtil.getHashFromByteArray(itemBytes); return NoUtil.getHashFromByteArray(itemBytes);
} catch (IOException e) {
throw new NoDashFatalException("IO Exception encountered while generating user hash.", e);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
throw new NoDashFatalException("IllegalArgument Exception encountered while generating user hash.", e); throw new NoDashFatalException("IllegalArgument Exception encountered while generating user hash.", e);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {