Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create function dbo.CalculateBetResult
- (
- @serverSeed binary(32),
- @clientSeed binary(8)
- )
- returns bigint
- as
- begin
- declare @hash binary(64)
- declare @index int
- declare @r bigint
- set @hash = HASHBYTES('SHA2_512', @serverSeed+@clientSeed)
- set @hash = HASHBYTES('SHA2_512', @hash)
- while 1=1
- begin
- set @index = 1
- while @index <= 64 - 3
- begin
- set @r = cast(substring(@hash, @index, 3) as bigint)
- if @r < 16000000
- return @r % 1000000
- set @index += 3
- end
- set @hash = HASHBYTES('SHA2_512', @hash)
- end
- return -1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement