rogusdev / fast32 Goto Github PK
View Code? Open in Web Editor NEWBase 32 + 64 encoding and decoding identifiers + bytes in rust, quickly
License: MIT License
Base 32 + 64 encoding and decoding identifiers + bytes in rust, quickly
License: MIT License
Hello, I was using this library to check if a number was in base32 using the decode function.
fn is_base32_number(s: &str) -> bool {
match RFC4648.decode(s.as_bytes()) {
Ok(_) => true,
Err(_) => false,
}
}
When I pass a string that has a length less than 6 to the function, it panics with a "attempt to subtract with overflow" without throwing a DecodeError, which is caused by the following function:
Line 154 in e9d8048
a[len - 6]
.
I made what i feel like is a bandaid fix, but I have only been writing rust for like a week or 2 so I am not sure if it follows the best conventions and guidelines.
I am sure this is not an intended function of decode method, but from what I have been reading it would follow Rust conventions to make it as safe as possible.
I want to encode into lowercase crockford Base32. Currently I use to_ascii_lowercase
to do this in-place. Although it avoids character tables and doesn't support crockford encoding, an alternative project, base32ct, provides a means of encoding directly into lowercase base32.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.