<commit_before>/*
 * Id is an object representation of a peer Id. a peer Id is a multihash
 */

var fs = require('fs')
var multihashing = require('multihashing')
var base58 = require('bs58')
var forge = require('node-forge')
var protobuf = require('protocol-buffers')

var isNode = !global.window

// protobuf read from file
var messages = isNode ? protobuf(fs.readFileSync(__dirname + '/../pb/crypto.proto')) : protobuf(require('buffer!./../pb/crypto.proto'))

// for some reason webpack can only find forge at forge.forge().someFunction()
// browser should be able to just use forge.someFunction()
// this is only happening when js-ipfs bundles peer-id module
/* if(!isNode){
  forge = forge.forge()
} */

exports = module.exports = Id

exports.Buffer = Buffer

function Id (id, privKey, pubKey) {
  var self = this

  if (!(self instanceof Id)) {
    throw new Error('Id must be called with new')
  }

  self.privKey = privKey
  self.pubKey = pubKey
  self.id = id // multihash - sha256 - buffer

  // pretty print

  self.toPrint = function () {
    return {
      id: self.toB58String(),
      privKey: privKey.toString('hex'),
      pubKey: pubKey.toString('hex')
    }
  }

  // encode/decode functions
<commit_msg>removed node forge bundle comment<commit_after>/*
 * Id is an object representation of a peer Id. a peer Id is a multihash
 */

var fs = require('fs')
var multihashing = require('multihashing')
var base58 = require('bs58')
var forge = require('node-forge')
var protobuf = require('protocol-buffers')

var isNode = !global.window

// protobuf read from file
var messages = isNode ? protobuf(fs.readFileSync(__dirname + '/../pb/crypto.proto')) : protobuf(require('buffer!./../pb/crypto.proto'))

exports = module.exports = Id

exports.Buffer = Buffer

function Id (id, privKey, pubKey) {
  var self = this

  if (!(self instanceof Id)) {
    throw new Error('Id must be called with new')
  }

  self.privKey = privKey
  self.pubKey = pubKey
  self.id = id // multihash - sha256 - buffer

  // pretty print

  self.toPrint = function () {
    return {
      id: self.toB58String(),
      privKey: privKey.toString('hex'),
      pubKey: pubKey.toString('hex')
    }
  }

  // encode/decode functions

{'fraction_non_alphanumeric': 0.13525698827772767, 'fraction_numerical': 0.008115419296663661, 'mean_word_length': 3.30873786407767, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6364081', 'n_tokens_mistral': 720, 'n_tokens_neox': 690, 'n_words': 216}