Equivalent for generate_hash in javascript

Hello;

If I need to use frappe.generate_hash in javascript, then what is the equivalent?

@Mohammed_Redha, appreciate your kindly help as I got this from below link that:

Regards
Bilal

1 Like

@bghayad you have to define a new javascript function in your custom app :

   String.prototype.hash = function() {
  var self = this, range = Array(this.length);
  for(var i = 0; i < this.length; i++) {
    range[i] = i;
  }
  return Array.prototype.map.call(range, function(i) {
    return self.charCodeAt(i).toString(16);
  }).join('');
} 

How to use it:

"Lorem Ipsum".hash()
"4c6f72656d20497073756d"
1 Like