Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is ActiveSupport::SecureRandom secure?

Is the ActiveSupport::SecureRandom secure in the way that it is 'impossible' to figure out random numbers or is it secure in the way that it will return UUIDs?

like image 797
Flexo Avatar asked Jul 08 '10 08:07

Flexo


People also ask

What is SecureRandom in Ruby?

Secure random number generator interface. This library is an interface to secure random number generators which are suitable for generating session keys in HTTP cookies, etc. You can use this library in your application by requiring it: require 'securerandom'

What is SecureRandom hex?

SecureRandom. hex generates a random hexadecimal string. The argument n specifies the length, in bytes, of the random number to be generated. The length of the resulting hexadecimal string is twice n. If n is not specified or is nil, 16 is assumed.


Video Answer


1 Answers

The security of the random number (and its application) comes from how sufficiently random it is for cryptographic purposes. The quality of the randomness relies to a great extent on the entropy that the system can provide such as through interfaces like /dev/urandom on Linux. For it to be secure, an attacker must not be able to guess the next random number, given some sequence of previously generated random numbers.

You could use ActiveRecord::SecureRandom as part of an implementation for creating UUID (version 4) but they are not directly related

like image 84
bjg Avatar answered Oct 08 '22 09:10

bjg