Module: PkernelJce::Converter

Included in:
Pkernel::Converter
Defined in:
lib/pkernel_jce/converter.rb

Overview

Common converter between different format

Instance Method Summary collapse

Instance Method Details

#from_b64(str) ⇒ Object

end to_b64



24
25
26
# File 'lib/pkernel_jce/converter.rb', line 24

def from_b64(str)
  java.util.Base64.decoder.decode(str)
end

#from_hex(str) ⇒ Object

end to_hex



14
15
16
# File 'lib/pkernel_jce/converter.rb', line 14

def from_hex(str)
  org.bouncycastle.util.encoders.Hex.decode(str)
end

#from_mb64(str) ⇒ Object

Convert from MimeEncoder base64 format



40
41
42
# File 'lib/pkernel_jce/converter.rb', line 40

def from_mb64(str)
  java.util.Base64.getMimeDecoder.decode(str)
end

#to_b64(bin) ⇒ Object

end from_hex



19
20
21
# File 'lib/pkernel_jce/converter.rb', line 19

def to_b64(bin)
  String.from_java_bytes(java.util.Base64.encoder.encode(bin))
end

#to_hex(bin) ⇒ Object



9
10
11
# File 'lib/pkernel_jce/converter.rb', line 9

def to_hex(bin)
  String.from_java_bytes(org.bouncycastle.util.encoders.Hex.encode(bin))
end

#to_mb64(bin) ⇒ Object

Convert to MimeEncoder base64 format which limit per line 80 characters



32
33
34
# File 'lib/pkernel_jce/converter.rb', line 32

def to_mb64(bin)
  String.from_java_bytes(java.util.Base64.getMimeEncoder.encode(bin))
end