Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

generate uuid from string js

const stringToUuid = (str) => {
  str = str.replace('-', '');
  return 'xxxxxxxx-xxxx-4xxx-xxxx-xxxxxxxxxxxx'.replace(/[x]/g, function(c, p) {
    return str[p % str.length];
  });
}

var input  = "813538-359512";
var output = stringToUuid(input);

console.log('Input: ' + input);
console.log('Output: ' + output);
 
PREVIOUS NEXT
Tagged: #generate #uuid #string #js
ADD COMMENT
Topic
Name
6+3 =