How to use the rfc4648.base32.stringify function in rfc4648

To help you get started, we’ve selected a few rfc4648 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github abrasive / mygov-totp-enroll / main.js View on Github external
function makeQR(secret) {
    secret32 = base32.stringify(base64.parse(secret))
    secret32 = secret32.replace(/=+$/, "")
    totp_uri = 'otpauth://totp/myGov?secret=' + secret32 + '&algorithm=SHA512'

    qrcode.toDataURL(totp_uri)
        .then(url => {
            setStatus("Enroll this secret in your TOTP client and enter the current code");
            setDetail(totp_uri + '<p><img src="' + url + '">');
            showCodeForm(true);
        })
        .catch(err =&gt; {
            setError("QR encoding error", err);
        })
}
</p>
github EdgeApp / edge-core-js / src / modules / account / account-state.js View on Github external
enableOtp (otpTimeout: number) {
    const { ai } = this
    const login = this.loginTree
    checkLogin(login)
    const otpKey =
      login.otpKey != null
        ? fixOtpKey(login.otpKey)
        : base32.stringify(ai.props.io.random(10))

    const kit = {
      serverPath: '/v2/login/otp',
      server: {
        otpKey,
        otpTimeout
      },
      stash: {
        otpKey,
        otpResetDate: void 0,
        otpTimeout
      },
      login: {
        otpKey,
        otpResetDate: void 0,
        otpTimeout
github paragonie / ciphersweet-js / lib / backend / fipsrypto.js View on Github external
async getIndexTypeColumn(tableName, fieldName, indexName)
    {
        let hash = await Util.hmac(
            'sha384',
            Util.pack([
                await Util.toBuffer(fieldName),
                await Util.toBuffer(indexName)
            ]),
            tableName,
            true
        );
        return base32.stringify(hash.slice(0, 8))
            .toLowerCase()
            .replace(/=+$/, '');
    }
github paragonie / ciphersweet-js / lib / backend / moderncrypto.js View on Github external
async getIndexTypeColumn(tableName, fieldName, indexName)
    {
        if (!sodium) sodium = await SodiumPlus.auto();
        tableName = await Util.toBuffer(tableName);
        fieldName = await Util.toBuffer(fieldName);
        indexName = await Util.toBuffer(indexName);

        let hash = await sodium.crypto_generichash(tableName, null, 16);
        let shorthash = await sodium.crypto_shorthash(
            Util.pack([fieldName, indexName]),
            new CryptographyKey(hash)
        );
        return base32.stringify(shorthash)
            .toLowerCase()
            .replace(/=+$/, '');
    }
github EdgeApp / edge-core-js / src / core / login / otp.js View on Github external
export async function enableOtp(
  ai: ApiInput,
  accountId: string,
  otpTimeout: number
) {
  const { loginTree } = ai.props.state.accounts[accountId]

  const otpKey =
    loginTree.otpKey != null
      ? fixOtpKey(loginTree.otpKey)
      : base32.stringify(ai.props.io.random(10))

  const kit: LoginKit = {
    serverPath: '/v2/login/otp',
    server: {
      otpKey,
      otpTimeout
    },
    stash: {
      otpKey,
      otpResetDate: void 0,
      otpTimeout
    },
    login: {
      otpKey,
      otpResetDate: void 0,
      otpTimeout