Class: Ccrypto::Java::SecureRandomEngine
- Inherits:
-
Object
- Object
- Ccrypto::Java::SecureRandomEngine
show all
- Extended by:
- DataConversion
- Includes:
- TR::CondUtils
- Defined in:
- lib/ccrypto/java/engines/secure_random_engine.rb
Class Method Summary
collapse
from_b64, from_b64_mime, from_hex, included, logger, to_b64, to_b64_mime, to_bin, to_hex, to_java_bytes, to_str
Class Method Details
.random_alphanu(size, &block) ⇒ Object
29
30
31
|
# File 'lib/ccrypto/java/engines/secure_random_engine.rb', line 29
def self.random_alphanu(size, &block)
SecureRandom.alphanumeric(size)
end
|
.random_b64(size, &block) ⇒ Object
21
22
23
|
# File 'lib/ccrypto/java/engines/secure_random_engine.rb', line 21
def self.random_b64(size, &block)
to_b64(random_bytes(size, &block))
end
|
.random_bytes(size, &block) ⇒ Object
11
12
13
14
15
|
# File 'lib/ccrypto/java/engines/secure_random_engine.rb', line 11
def self.random_bytes(size, &block)
buf = ::Java::byte[size].new
engine(&block).next_bytes(buf)
buf
end
|
.random_hex(size, &block) ⇒ Object
17
18
19
|
# File 'lib/ccrypto/java/engines/secure_random_engine.rb', line 17
def self.random_hex(size,&block)
to_hex(random_bytes(size,&block))
end
|
.random_number(val, &block) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/ccrypto/java/engines/secure_random_engine.rb', line 33
def self.random_number(val, &block)
if val.is_a?(Range)
v = engine(&block).next_int(val.max)
if v < val.min
v = v+val.min
end
v
elsif val.is_a?(Integer)
engine(&block).next_int(val)
elsif is_empty?(val)
engine(&block).next_double
end
end
|
.random_uuid ⇒ Object
25
26
27
|
# File 'lib/ccrypto/java/engines/secure_random_engine.rb', line 25
def self.random_uuid
java.util.UUID.randomUUID.to_s
end
|