<commit_before>var crypto = require('crypto');
var md5 = crypto.createHash('md5');

var Hashkit = function(options){
    this.chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
    this.salt = '';
    this.padding = 1;
};

Hashkit.prototype.encode = function(i){
    return this.baseEncode(i);
};

Hashkit.prototype.decode = function(s){
    return this.baseDecode(s);
};

Hashkit.prototype.baseEncode = function(i){
    if (i == 0) return this.chars[0];

    var s = '';
    var base = this.chars.length;

    while (i > 0) {
        s = this.chars[i % base] + "" + s;
        i = Math.floor(i / base);
    }

    return s;
};

Hashkit.prototype.baseDecode = function(s){
    var n = 0;
    var base = this.chars.length;

    for (var i = 0; i < s.length; i++) {
        n += this.chars.indexOf(s[i]) * Math.pow(base, s.length - i - 1);
    }

    return n;
};

Hashkit.prototype.getSeed = function(i) {
    var hash = md5.update(i + "" + this.salt).digest('hex');
    $dec = hexdec(substr($hash, 0, $padding));
    $num = $dec % pow(10, $padding);
    if ($num == 0) $num = 1;
    $num = str_pad($num, $padding, '0');

    return $num;
};

exports = module.exports = Hashkit;<commit_msg>Implemented encode/decode functionality.<commit_after>(function(){
var crypto = require('crypto');

var Hashkit = function(options){
    this.chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
    this.salt = '';
    this.padding = 1;
};

// Converts a number into an encoded string
Hashkit.prototype.encode = function(i){
    if (this.salt != '' && this.padding > 0) {
        var seed = this.getSeed(i, this.salt, this.padding);
        i = parseInt(seed + '' + i);
    }
    return this.baseEncode(i);
};

// Converts an encoded string into a number
Hashkit.prototype.decode = function(s){
    var num = this.baseDecode(s);

    if (this.salt != '' && this.padding > 0) {
        return parseInt(num.toString().substr(this.padding));
    }

    return num;
};

// Converts a number into a base-n string
Hashkit.prototype.baseEncode = function(i){
    if (i == 0) return this.chars[0];

    var s = '';
    var base = this.chars.length;

    while (i > 0) {
        s = this.chars[i % base] + '' + s;
        i = Math.floor(i / base);
    }

    return s;
};

// Converts a base-n string into a number
Hashkit.prototype.baseDecode = function(s){
    var n = 0;
    var base = this.chars.length;

    for (var i = 0; i < s.length; i++) {
        n += this.chars.indexOf(s[i]) * Math.pow(base, s.length - i - 1);
    }

    return n;
};

// Gets the hash value of a string
Hashkit.prototype.getHash = function(s){
    return crypto.createHash('md5').update(s).digest('hex');
};

// Gets a seed value for number encoding
Hashkit.prototype.getSeed = function(i, salt, length) {
    var hash = this.getHash(i + '' + salt);
    var dec = parseInt(hash.substr(0, length), 16);
    var base = Math.pow(10, length);
    var num = dec % base;

    if (num == 0) num = 1;

    while (num < base / 10) {
        num = num * 10;
    }

    return num;
};

// Export for nodejs, AMD, or browser
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
    module.exports = Hashkit;
}
else {
    if (typeof define === 'function' && define.amd) {
        define([], function(){
            return Hashkit;
        });
    }
    else {
        window.Hashkit = Hashkit;
    }
}
})();
{'fraction_non_alphanumeric': 0.16530373831775702, 'fraction_numerical': 0.01664719626168224, 'mean_word_length': 2.6709539121114685, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 7, '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': '440938', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1176, 'n_words': 295}