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.



17
18
19
# File 'lib/xmldsign/digests/gost.rb', line 17

def initialize(data)
  @data = data
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

.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



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

def base64
  Base64.encode64(binary).strip
end

#binaryObject



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'ext/xmldsign/xmldsign_ext.c', line 45

static VALUE rb_gost_digest(VALUE self)
{
  char sum[32];

  VALUE data;

  data = rb_iv_get(self, "@data");

  if( digest(StringValuePtr(data), sum) )
    return rb_str_new2( substring(sum, 0, 32) );
  else
    return Qfalse;
}

#hexObject



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

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