Here is a simple example I wrote to convert and convert back using the 2 convert methods, I also checked it with a fixed string
declare @VB1 VARBINARY(500),@VB2 VARBINARY(500),@VB3 VARBINARY(500)
declare @S1 VARCHAR(500)
SET @VB1=HASHBYTES('SHA1','Test')
SET @S1=CONVERT(varchar(500),@VB1,2)
SET @VB2=CONVERT(varbinary(500),@S1,2)
SET @VB3=CONVERT(varbinary(500),'640AB2BAE07BEDC4C163F679A746F7AB7FB5D1FA',2)
SELECT @VB1,@S1,@VB2,@VB3
IF @VB1=@VB2 PRINT 'They Match(2)'
IF @VB1=@VB3 PRINT 'They Match(3)'
PRINT str(Len(@VB1))
PRINT str(Len(@S1))
PRINT str(Len(@VB2))
SET @VB1=HASHBYTES('SHA1','Test')
SET @S1=CONVERT(varchar(500),@VB1,1)
SET @VB2=CONVERT(varbinary(500),@S1,1)
SELECT @VB1,@S1,@VB2
IF @VB1=@VB2 PRINT 'They Match(1)'
PRINT str(Len(@VB1))
PRINT str(Len(@S1))
PRINT str(Len(@VB2))
and the output
||| 0x640AB2BAE07BEDC4C163F679A746F7AB7FB5D1FA|640AB2BAE07BEDC4C163F679A746F7AB7FB5D1FA|0x640AB2BAE07BEDC4C163F679A746F7AB7FB5D1FA|0x640AB2BAE07BEDC4C163F679A746F7AB7FB5D1FA
(1 row(s) affected)
They Match(2)
They Match(3)
20
40
20
|| 0x640AB2BAE07BEDC4C163F679A746F7AB7FB5D1FA|0x640AB2BAE07BEDC4C163F679A746F7AB7FB5D1FA|0x640AB2BAE07BEDC4C163F679A746F7AB7FB5D1FA
(1 row(s) affected)
They Match(1)
20
42
20