Using T-SQL as per the snippets below, which method is superior (or is it a tie)?
-- method 1: DIY
SET @Salt = ''
WHILE LEN(@Salt) < 72
BEGIN
SET @Salt = @Salt + CHAR(CONVERT(INT, Floor(RAND() * (126.0 - 33 + 1) + 33)))
END
-- method 2: concatenating 2 GUIDs
SET @Salt = CONVERT(VARCHAR(36), NEWID()) + CONVERT(VARCHAR(36), NEWID())```
Robert');DROP TABLE Students;--
in a salt. See obligatory XKCD, and this if you don't quite get it. Worry about unpredictability ofRAND()
andNEWID()
in whatever the environment is. WhatCONVERT(VARCHAR(36), NEWID())
does is language-dependent, thus off-topic. – fgrieu Nov 17 '20 at 07:12