Verify UUID from javascript similar to Hibernate. I know UUID is unique and no need to worry but out of curiosity I want to dig down more and want my application to generate similar UUID from javascript and hibernate.
In Hibernate
@Id
@GeneratedValue(generator = "uuid2")
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "id", columnDefinition = "BINARY(16)")
private UUID id;
Generated by Hibernate
"6613d9b1-dcc8-47bf-8d85-bc4415385c42"
"2f160bae-f53a-472b-93eb-5ecc352fbac7"
In Javascript (https://stackoverflow.com/a/2117523/2381453)
function uuidv4() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
)
}
console.log(uuidv4());
Generated by JavaScript
"37ad0abe-fbf0-4a91-aa59-e02e81ff1a96"
"c5969fe4-dcbf-4af6-93f5-4a7011dd6f24"
So is it the same?