mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 22:45:45 +01:00
encode unique keys with Base62 for shorter keys
This commit is contained in:
@@ -38,6 +38,8 @@ import com.google.inject.Singleton;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.util.Base62;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.Random;
|
||||
@@ -76,9 +78,9 @@ public class DefaultKeyGenerator implements KeyGenerator
|
||||
{
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
buffer.append(Long.toHexString(System.currentTimeMillis()));
|
||||
buffer.append(Long.toHexString(sessionKey.incrementAndGet()));
|
||||
buffer.append(Integer.toHexString(createRandom()));
|
||||
buffer.append(Base62.encode(createRandom()));
|
||||
buffer.append(Base62.encode(System.currentTimeMillis()));
|
||||
buffer.append(Base62.encode(sessionKey.incrementAndGet()));
|
||||
|
||||
String key = buffer.toString();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user