Comments (1)
Sure!
In order to guarantee an upper limit on the output, just put an upper limit on the input. With the integer types tinyint
, smallint
or int
, you should not exceed 12 characters of output at all. If you need larger inputs, e.g. from bigint
, your maximum input number for n
characters of output is 51^n − 1
. There's no other way to make the upper limit work.
Since what you want is 12 characters of output for every input, you need a lower limit as well.
The only way to make that work is by padding (e.g. on the left). Pad the output with a fixed character that is not in the alphabet of this library, up to your desired character length. If you need more variation and "randomness" in your output, consider using a set of multiple padding characters, neither of which may be in this library's alphabet. Choose the next padding character from set set randomly.
Hope that helps!
from shorturl.
Related Issues (14)
- In the Java class, index should be casted as long HOT 2
- Is it safe to change the alphabet used? HOT 3
- Concurrency issue HOT 1
- Swift 4 version HOT 1
- Supporting long/big-int numbers! HOT 2
- what if path starts with "2" HOT 4
- C version HOT 1
- Please look at my Gist for a way to enhance your ShortURL HOT 2
- golang? HOT 1
- Note Limit up to 1999999999 HOT 2
- on 64bit php, PHP_INT_MAX is decoded as a float HOT 6
- in 64bit php, everything between 0x7ffffffffffffE00 - PHP_INT_MAX is returned as float HOT 1
- in 64bit php, everything >= 0xE33BF7209CBFD54 is decoded (or encoded?) incorrectly HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shorturl.