Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify isBase32 for option to use Crockford Base32 #1857

Closed
sunwukonga opened this issue Nov 3, 2021 · 5 comments
Closed

Modify isBase32 for option to use Crockford Base32 #1857

sunwukonga opened this issue Nov 3, 2021 · 5 comments

Comments

@sunwukonga
Copy link

sunwukonga commented Nov 3, 2021

Seeking willingness to incorporate a PR based on the following:

Crockford Base32

Add option crockford: bool to isBase32

isBase32(str [, options]) where options is {crockford: false} by default.

Usage: isBase32("CD89FGE", {crockford: true})

Example implementation:

import assertString from './util/assertString';
import merge from './util/merge';

const base32 = /^[A-Z2-7]+=*$/;
const crockfordBase32 = /^[A-HJKMNP-UW-Z0-9]+=*$/;

const defaultBase32Options = {
  crockford: false,
};

export default function isBase32(str, options) {
  assertString(str);
  options = merge(options, defaultBase32Options);
  const len = str.length;

  if (options.crockford) {
    return crockfordBase32.test(str);
  }

  if (len % 8 === 0 && base32.test(str)) {
    return true;
  }
  return false;
}
@caleberi
Copy link

caleberi commented Nov 9, 2021

@sunwukonga could you please assign this issue to me .

@sunwukonga
Copy link
Author

@sunwukonga could you please assign this issue to me .

I don't have write access to this repository. You'll need one of the members to do that for you.

CC: @tux-tn @ezkemboi @profnandaa

@caleberi
Copy link

caleberi commented Nov 9, 2021

@ezkemboi could you please assign this issue to me

@tux-tn
Copy link
Member

tux-tn commented Nov 10, 2021

Hello and thank you for the suggestion,
@caleberi There is no such thing as assigning an issue to someone here. If you think you can add the feature, feel free to open a PR!

@caleberi
Copy link

Okay 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants