Comments (2)
01FZD39998855SS2YG4XP4T14P
is a valid base32 encoded string and a base32 string should round trip between b32decode
and b32encode
to the same value. If it doesn't then there's a bug there. It has nothing to do with ulid.
I found a different encoding package crockford-base32
that isn't bugged:
import b32decode from 'base32-decode';
import b32encode from 'base32-encode';
import { CrockfordBase32 } from 'crockford-base32';
const uid = '01FZD39998855SS2YG4XP4T14P';
const buffer = CrockfordBase32.decode(uid);
console.log('decoded', new Uint8Array(buffer).toString());
const res = CrockfordBase32.encode(buffer);
console.log('encoded', res);
const decoded = b32decode(uid, 'Crockford');
console.log('DECODED', new Uint8Array(decoded).toString());
const encoded = b32encode(decoded, 'Crockford');
console.log('ENCODED', encoded);
Result:
decoded 1,127,218,52,165,40,65,75,156,139,208,39,108,77,4,150
encoded 01FZD39998855SS2YG4XP4T14P
DECODED 0,95,246,141,41,74,16,82,231,34,244,9,219,19,65,37
ENCODED 01FZD39998855SS2YG4XP4T14M
Run it on stackblitz:
https://stackblitz.com/edit/js-esmrfr
from javascript.
Thanks @samal-rasmussen!
from javascript.
Related Issues (20)
- isUlid
- dist _index.js#L59
- License violation HOT 20
- Where is ulid.js HOT 3
- Support for RFC 4648 base32? HOT 2
- First and Last IDs for Timestamp HOT 4
- Is there a way to get the timestamp from a given ULID? HOT 3
- PRNG inconsistency HOT 1
- Crypto API isn't detected on alternative platforms HOT 5
- Monotonically Increasing Guarantee
- is_ulid(x) HOT 3
- Generate time from shortened ulid?
- Random bias?
- Not available in web workers
- Maintainers HOT 4
- Please Upgrade Your Package HOT 1
- Error in worker HOT 2
- issue 1
- issue2
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 javascript.