Class: Xmldsign::Digests::Gost

Inherits:
Object
  • Object
show all
Defined in:
lib/xmldsign/digests/gost.rb,
ext/xmldsign/xmldsign_ext.c

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Gost

Returns a new instance of Gost.



20
21
22
# File 'lib/xmldsign/digests/gost.rb', line 20

def initialize(data)
  @data = data.to_s
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/xmldsign/digests/gost.rb', line 6

def data
  @data
end

Class Method Details

.base64(data) ⇒ Object



9
10
11
# File 'lib/xmldsign/digests/gost.rb', line 9

def base64(data)
  new(data).base64
end

.binary(data) ⇒ Object



15
16
17
# File 'lib/xmldsign/digests/gost.rb', line 15

def binary(data)
  new(data).binary
end

.hex(data) ⇒ Object



12
13
14
# File 'lib/xmldsign/digests/gost.rb', line 12

def hex(data)
  new(data).hex
end

Instance Method Details

#base64Object



24
25
26
# File 'lib/xmldsign/digests/gost.rb', line 24

def base64
  Base64.strict_encode64(binary(data))
end

#binary(data) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'ext/xmldsign/xmldsign_ext.c', line 37

static VALUE rb_gost_digest(VALUE self, VALUE data)
{
  byte sum[32];

  if( digest(StringValuePtr(data), sum) )
    return rb_str_new( sum, 32 );
  else
    return Qfalse;
}

#hexObject



28
29
30
# File 'lib/xmldsign/digests/gost.rb', line 28

def hex
  binary(data).bytes.inject("") { |hex, b| hex << b.to_s(16) }
end