aboutsummaryrefslogtreecommitdiffstats
path: root/main/src
diff options
context:
space:
mode:
authorblafoo <github@blafoo.de>2012-02-21 22:13:24 +0100
committerblafoo <github@blafoo.de>2012-02-23 23:31:32 +0100
commit7ac4206e7c0308d2127845d7bf9214e73b845295 (patch)
treee76fd3a8c17c0a2cdd985ca7e393f8d072e24d05 /main/src
parent6b58e073439bec94f0bbe59284e7d9bcab329f7f (diff)
downloadcgeo-7ac4206e7c0308d2127845d7bf9214e73b845295.zip
cgeo-7ac4206e7c0308d2127845d7bf9214e73b845295.tar.gz
cgeo-7ac4206e7c0308d2127845d7bf9214e73b845295.tar.bz2
Unified methods for BASE 31
Diffstat (limited to 'main/src')
-rw-r--r--main/src/cgeo/geocaching/cgCache.java4
-rw-r--r--main/src/cgeo/geocaching/utils/CryptUtils.java27
2 files changed, 2 insertions, 29 deletions
diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java
index 0197248..72e12a5 100644
--- a/main/src/cgeo/geocaching/cgCache.java
+++ b/main/src/cgeo/geocaching/cgCache.java
@@ -5,6 +5,7 @@ import cgeo.geocaching.activity.IAbstractActivity;
import cgeo.geocaching.connector.ConnectorFactory;
import cgeo.geocaching.connector.GCConnector;
import cgeo.geocaching.connector.IConnector;
+import cgeo.geocaching.connector.gc.GCBase;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.LoadFlags.RemoveFlag;
@@ -14,7 +15,6 @@ import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.geopoint.GeopointFormatter;
import cgeo.geocaching.geopoint.GeopointParser;
import cgeo.geocaching.utils.CancellableHandler;
-import cgeo.geocaching.utils.CryptUtils;
import cgeo.geocaching.utils.LogTemplateProvider;
import org.apache.commons.collections.CollectionUtils;
@@ -577,7 +577,7 @@ public class cgCache implements ICache {
@Override
public String getCacheId() {
if (StringUtils.isBlank(cacheId) && getConnector().equals(GCConnector.getInstance())) {
- return CryptUtils.convertToGcBase31(geocode);
+ return String.valueOf(GCBase.gccodeToGCId(geocode));
}
return cacheId;
diff --git a/main/src/cgeo/geocaching/utils/CryptUtils.java b/main/src/cgeo/geocaching/utils/CryptUtils.java
index 08703d3..345af88 100644
--- a/main/src/cgeo/geocaching/utils/CryptUtils.java
+++ b/main/src/cgeo/geocaching/utils/CryptUtils.java
@@ -111,31 +111,4 @@ public final class CryptUtils {
return buffer;
}
- public static String convertToGcBase31(final String gccode) {
- final String alphabet = "0123456789ABCDEFGHJKMNPQRTVWXYZ";
-
- if (null == gccode) {
- return "";
- }
-
- char[] characters = gccode.toUpperCase().toCharArray();
-
- if (characters.length <= 2) {
- return "";
- }
-
- final int base = (characters.length <= 5 || (characters.length == 6 && alphabet.indexOf(characters[2]) < 16)) ? 16 : 31;
- int result = 0;
-
- for (int i = 2; i < characters.length; i++) {
- result *= base;
- result += alphabet.indexOf(characters[i]);
- }
-
- if (31 == base) {
- result += Math.pow(16, 4) - 16 * Math.pow(31, 3);
- }
-
- return Integer.toString(result);
- }
}