/** * Created by neo on 3/6/17. */ // debug shim (function () { if (typeof window.debug !== 'object') { window.debug = { log: function () { }, type: function () { }, error: function () { }, warn: function () { }, info: function () { } }; } })(); // can't get browserify-shim to work right // let's just make it work here window.$ = window.jQuery = require('jquery'); // include bootstrap css and javascript require('./index.css'); require('bootstrap'); // use hasher for application page management var hasher = require('hasher'); hasher.prependHash = '!'; hasher.separator = '/'; // include/configure highlight.js var hljs = require('highlight.js'); hljs.configure({ tabReplace: ' '.repeat(4) }); // use HTML Lint (will display later) var htmlLint = require('htmllint'); // js-beautify libraries var beautify_js = require('js-beautify').js; var beautify_css = require('js-beautify').css; var beautify_html = require('js-beautify').html; // xml-beautify library var beautify_xml = require('xml-beautifier'); // sql-formatter library var beautify_sql = require('sql-formatter'); // bcrypt-js library var bcrypt = require('bcryptjs'); // forge library var forge = require('node-forge'); // gencryption var gencryption = require("gencryption"); var cryptoShim = { shim: { out: function (md) { return md.digest().toHex(); } }, MD5: function () { var type = 'md5'; cryptoShim.shim[type] = typeof cryptoShim.shim[type] === 'undefined' ? forge.md[type].create() : cryptoShim.shim[type]; cryptoShim.shim[type].update.apply(this, arguments); return cryptoShim.shim.out(cryptoShim.shim[type]); }, SHA1: function () { var type = 'sha1'; cryptoShim.shim[type] = typeof cryptoShim.shim[type] === 'undefined' ? forge.md[type].create() : cryptoShim.shim[type]; cryptoShim.shim[type].update.apply(this, arguments); return cryptoShim.shim.out(cryptoShim.shim[type]); }, RIPEMD160: function () { return CryptoJS.RIPEMD160.apply(this, arguments).toString(CryptoJS.enc.Hex); }, bcrypt: function (stringIn) { return bcrypt.hashSync(stringIn, 10); } }; /** * JSON linting! * @param json */ var jsonLint = function (json) { return typeof json !== 'string' ? JSON.stringify(json, undefined, 4) : jsonLint(JSON.parse(json)); }; var hashShim = { /** * Returns hash, code, and type based on hashIn and separator * @param hashIn * @param separator * @return {{type: string, code: string, hash: string}} */ getHash: function (hashIn, separator) { hashIn = typeof hashIn !== 'string' ? hasher.getHash() : hashIn; separator = typeof separator !== 'string' ? hasher.separator : separator; var split = hashIn.split(separator, 3); return { 'type': typeof split[0] === 'string' ? split[0] : '', 'code': typeof split[1] === 'string' ? atob(split[1]) : '', 'hash': typeof split[2] === 'string' ? atob(split[2]) : '' }; }, /** * Compares the first substring of separator with one and two * @param one * @param two * @param separator * @returns {boolean} */ hashTypeCompare: function (one, two, separator) { separator = typeof separator !== 'string' ? hasher.separator : separator; var oneS = one.split(separator, 1)[0]; var twoS = two.split(separator, 1)[0]; debug.type("hashTypeCompare", "one: {" + oneS + "} two: {" + twoS + "} === " + (oneS === twoS ? 'true' : 'false')); return oneS === twoS; }, /** * Calls hasher.setHash() */ setHash: function (path) { debug.type("setHash() in", JSON.stringify(arguments)); // arguments[0]; // = type arguments[1] = btoa(arguments[1]); // = code arguments[2] = typeof arguments[2] !== 'undefined' ? btoa(arguments[2]) : arguments[2]; // hash debug.type("setHash() out", JSON.stringify(arguments)); hasher.setHash.apply(this, arguments); }, /** * Calls hasher.replaceHash() */ replaceHash: function (path) { debug.type("replaceHash() in", JSON.stringify(arguments)); // arguments[0]; // = type arguments[1] = btoa(arguments[1]); // = code arguments[2] = typeof arguments[2] !== 'undefined' ? btoa(arguments[2]) : arguments[2]; // hash debug.type("replaceHash() out", JSON.stringify(arguments)); hasher.replaceHash.apply(this, arguments); } }; var config = { _valid_tabs: [], html: { name: "HTML Linter", text: "HTML" }, json: { name: "JSON Linter", text: "JSON" }, xml: { name: "XML Linter", text: "XML" }, css: { name: "CSS Linter", text: "CSS" }, js: { name: "JS Linter", text: "JS" }, sql: { name: "SQL Linter", text: "SQL" }, encode_decode: { name: "Encode/Decode", text: "Encode/Decode", tabs: { urlencode: { name: "URL Encoder", text: "URLEncode" }, urldecode: { name: "URL Decoder", text: "URLDecode" }, base64encode: { name: "Base64 Encoder", text: "Base64Encode" }, base64decode: { name: "Base64 Decoder", text: "Base64Decode" } } }, hash_tools: { name: "Hash Tools", text: "Hash Tools", tabs: { md_hash: { name: "MD Hasher", text: "MD" }, sha_hash: { name: "SHA Hasher", text: "SHA" }, ripemd_hash: { name: "RIPEMD Hasher", text: "RIPEMD" }, bcrypt_hash: { name: "BCrypt Hasher", text: "BCrypt" }, keccak_hash: { name: "Keccak Hasher", text: "Keccak" }, whirlpool_hash: { name: "Whirlpool Hasher", text: "Whirlpool" }, dss1_hash: { name: "DSS1 Hasher", text: "DSS1" } } }, encryption_tools: { name: "Encryption Tools", text: "Encryption", tabs: { aes_enc: { name: "AES Encryption", text: "AES" }, "3des_enc": { name: "Triple DES Encryption", text: "3-DES" }, rc4_enc: { name: "RC-4 Encryption", text: "RC4" }, rabbit_enc: { name: "Rabbit Encryption", text: "Rabbit" }, evpkdf_enc: { name: "Evpkdf Encryption", text: "Evpkdf" } } } }; $('window').ready(function () { // main I/O var input = $('#input'); var output = $('#output'); var navbar = $('#navbar').find('.nav'); Object.keys(config).forEach(function (key) { if (key[0] === '_') { return; } var id = key + '_tab'; var listItem = $('
  • ') .attr('id', id) .attr('data-name', config[key].name) .attr('data-function', key); var link = $('') .attr('href', '#') .html(config[key].text) .appendTo(listItem); if (config[key].hasOwnProperty('tabs')) { var tabs = config[key].tabs; listItem.addClass('dropdown'); link.addClass('dropdown-toggle') .attr('role', 'button') .attr('aria-expanded', 'false') .attr('data-toggle', 'dropdown'); $('') .addClass('caret') .appendTo(link); var ul = $('