From 7ac4206e7c0308d2127845d7bf9214e73b845295 Mon Sep 17 00:00:00 2001 From: blafoo Date: Tue, 21 Feb 2012 22:13:24 +0100 Subject: Unified methods for BASE 31 --- main/src/cgeo/geocaching/cgCache.java | 4 ++-- main/src/cgeo/geocaching/utils/CryptUtils.java | 27 -------------------------- 2 files changed, 2 insertions(+), 29 deletions(-) (limited to 'main/src') 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); - } } -- cgit v1.1