lib/generate.js
function generateKey(options) {
  // Options
  options = _.extend({
    length: 32,
    name: '',
    symbols: false,
    google: false,
    qrCode: false,
    type: 'base32'
  }, options || {});

  // Generate the random string
  var key = randomString(options);

  if (options.type === 'ascii') {
    return key;
  } else if (options.type === 'base32') {
    // Encode the ascii string into base32 and remove any `=` signs which google
    // doesn't like
    key = base32.encode(key).toString().replace(/=/g, '');

    return key;
  } else {
    throw new Error('InvalidKeyType');
  }
}
function generateKey(options) {
  // Options
  options = _.extend({
    length: 32,
    name: '',
    symbols: false,
    google: false,
    qrCode: false,
    type: 'base32'
  }, options || {});

  // Generate the random string
  var key = randomString(options);

  if (options.type === 'ascii') {
    return key;
  } else if (options.type === 'base32') {
    // Encode the ascii string into base32 and remove any `=` signs which google
    // doesn't like
    key = base32.encode(key).toString().replace(/=/g, '');

    return key;
  } else {
    throw new Error('InvalidKeyType');
  }
}
function generateKey ( options ) { // Options options = _ . extend ( { length : 32 , name : '' , symbols : false , google : false , qrCode : false , type : 'base32' } , options || { } ) ; // Generate the random string var key = randomString ( options ) ; if ( options . type === 'ascii' ) { return key ; } else if ( options . type === 'base32' ) { // Encode the ascii string into base32 and remove any `=` signs which google // doesn't like key = base32 . encode ( key ) . toString ( ) . replace ( / = / g , '' ) ; return key ; } else { throw new Error ( 'InvalidKeyType' ) ; } }
Generates a random base32 secret key and optionally a qrcode

@param     {Object}    options
@return    {Object}
Generates a random base32 secret key and optionally a qrcode