Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
is-canonical-base64
Advanced tools
Readme
a regular expression to test wether a string is a valid base64, without ambiguity.
Base64 encodes bytes (base 256, 8 bits each) as chars each representing
6 bits. That means a one byte buffer necessarily becomes 2 chars,
except only the top 2 bits of the last char are used (and the string
is then padded with an ==
to take the spaces those chars would be)
It's recommended that implementations encode zeros here, but many implementations (including node.js's) accept non-zeros here, but just ignore them.
This can be a problem for signed data, because if the signature signs base64, you must retain exactly the encoded representation (including any ambiguity). So, it's good to enforce that ambigious representations are rejected.
simple
var isCanonicalBase64 = require('canonical-base64')() //note, returns a function
isCanonicalBase64.test(string)
advanced: you may pass in a prefix and suffix, which is combined into the regular expression.
var isCanonicalBase64 = require('canonical-base64')('@', '(?:\.ed25519)')
isCanonicalBase64.test(string)
MIT
FAQs
test wether a base64 string will serialize the same after parsing
The npm package is-canonical-base64 receives a total of 118 weekly downloads. As such, is-canonical-base64 popularity was classified as not popular.
We found that is-canonical-base64 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.