Advertisement
meiji488

Untitled

Jul 8th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. create function dbo.CalculateBetResult
  2. (
  3. @serverSeed binary(32),
  4. @clientSeed binary(8)
  5. )
  6. returns bigint
  7. as
  8. begin
  9. declare @hash binary(64)
  10. declare @index int
  11. declare @r bigint
  12.  
  13. set @hash = HASHBYTES('SHA2_512', @serverSeed+@clientSeed)
  14. set @hash = HASHBYTES('SHA2_512', @hash)
  15. while 1=1
  16. begin
  17.  
  18. set @index = 1
  19. while @index <= 64 - 3
  20. begin
  21. set @r = cast(substring(@hash, @index, 3) as bigint)
  22. if @r < 16000000
  23. return @r % 1000000
  24. set @index += 3
  25. end
  26.  
  27. set @hash = HASHBYTES('SHA2_512', @hash)
  28.  
  29. end
  30. return -1
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement