Cherry picked more uuid code

pull/14/head
Sam Bosley 12 years ago
parent 868bc7cffd
commit c6968c9264

@ -247,6 +247,23 @@ public final class TagService {
}
}
public Long[] getEmergentTagIds() {
TodorooCursor<TagData> emergent = tagDataService.query(Query.select(TagData.ID)
.where(Functions.bitwiseAnd(TagData.FLAGS, TagData.FLAG_EMERGENT).gt(0)));
try {
Long[] tags = new Long[emergent.getCount()];
TagData data = new TagData();
for (int i = 0; i < emergent.getCount(); i++) {
emergent.moveToPosition(i);
data.readFromCursor(emergent);
tags[i] = data.getId();
}
return tags;
} finally {
emergent.close();
}
}
/**
* Return tags on the given task
*

@ -3,8 +3,6 @@ package com.todoroo.astrid.helper;
import java.security.SecureRandom;
import java.util.UUID;
import android.util.Base64;
import com.todoroo.andlib.utility.Pair;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
@ -57,18 +55,29 @@ public class UUIDHelper {
}
private static final String SALT = "$2a$10$2RHhxhKaPb4VXlQUJyBU/O"; //$NON-NLS-1$
private static final String BASE_64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./"; //$NON-NLS-1$
private static long bcryptToLong(String proofText) {
String a = BCrypt.hashpw(proofText, SALT);
int start = 29;
int endPlusOne = 60;
String b = a.substring(start, endPlusOne);
byte[] bytes = Base64.decode(b, Base64.DEFAULT);
long result = 1;
for (byte element : bytes) {
result = 31 * result + element;
for (int i = 0; i < b.length(); i++) {
result = 31 * result + iOf(b.charAt(i));
}
return result;
}
@SuppressWarnings("nls")
private static int iOf(char c) {
int index = BASE_64_CHARS.indexOf(c);
if (index < 0)
throw new RuntimeException("Base64Chars is wrong! No character " + c + " found. Probably needs to be replaces with something else");
return index;
}
}

Loading…
Cancel
Save