I need to find a way to include a very long string (~70,000 characters) in a URL. It is important for me to have the ability to implement back-forward functionality in a browser so that my application can respond and adjust its state when the URL changes.
One approach I am considering is using the following function to generate a hash code from the string:
String.prototype.hashCode = function () {
var hash = 0, i, char;
if (this.length == 0) return hash;
var l = this.length;
for (i = 0; i < l; i++) {
char = this.charCodeAt(i);
hash = ((hash << 5) - hash) + char;
hash |= 0; // Convert to 32bit integer
}
return hash;
};
My primary concern now is how can I retrieve the original string from its hash code?
Edits: I am also interested in exploring alternative methods for compressing such an extensive URL. Are there any other techniques I should consider?