ForgeTotal.js 5
ro

Total.js 5

Generarea de id-uri unice și de hash-uri

Total.js 5 · total5@0.0.19 utilitiesidssecurity Executată cu Total.js 5
  • UID() creează un id scurt, ordonat în timp, unic (12 caractere). Se sortează după momentul creării și este ceea ce validează tipul de intrare UID. Folosește-l drept cheie primară a documentelor tale.
  • GUID(length) creează un șir aleatoriu de lungimea cerută. Folosește-l pentru token-uri și nume de fișiere.
  • HASH(value) returnează un hash numeric rapid (necriptografic). Folosește-l pentru chei de cache, ETag-uri și sharding, niciodată pentru parole.
controllers/ids.js
exports.install = function() {
	ROUTE('GET /ids/', ids);
};

function ids($) {

	var a = UID();
	var b = UID();

	$.json({
		uid: a,
		uidlength: a.length,
		valid: a.isUID(),
		different: a !== b,
		guid: GUID(20),
		sameHash: HASH('total') === HASH('total'),
		otherHash: HASH('total') !== HASH('Total'),
		type: typeof(HASH('total'))
	});
}