"use strict";var _classCallCheck2=require("babel-runtime/helpers/classCallCheck"),_classCallCheck3=_interopRequireDefault(_classCallCheck2),_createClass2=require("babel-runtime/helpers/createClass"),_createClass3=_interopRequireDefault(_createClass2);function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}var sjcl=require("sjcl"),logger=require("./logger"),SecureRandomizer=function(){function a(){(0,_classCallCheck3.default)(this,a),logger.debug("Init Secure Randon"),this.sjclRandom=new sjcl.prng(10);try{logger.debug("Trying crypto");var b=require("crypto").randomBytes(1024).toString("hex"),c=sjcl.codec.hex.toBits(b);this.sjclRandom.addEntropy(c,void 0,"csprng"),this.isSeeded=!0}catch(a){logger.warn("Crypto: "+a),this.isSeeded=!1}}return(0,_createClass3.default)(a,[{key:"wordWith",value:function(a){if(!this.isSeeded)throw new Error("Can't user SecureRandon before seeding");var b=this.sjclRandom.randomWords(a/8,10);return sjcl.codec.hex.fromBits(b)}}]),a}();module.exports=new SecureRandomizer;