HMAC:SHA256 giving Error on Device

// Expert user has replied.
S Siddhant Wadhera 2 years 11 months ago
7 3 0

Hi
I am new to both ruby and rho mobile and currently i am trying to encrypt a key using HMAC-SHA2.

But when i try to use hmac = HMAC::SHA256.new(key) i get the error as given below in the log

RhoRuby| require_compiled: error: can not find digest/sha2.so

APP| App error: library not found for class Digest::SHA256 -- digest/sha2.so

Here is my Complete Code.

Controller.rb

require 'digest'
require 'digest/sha2'
require 'hmac-sha2'

def test_hmac
      key = '12344444'
      signature = 'abcdef'
      Alert.show_popup(key)
      puts "key :  #{key}"
      hmac = HMAC::SHA256.new(key)
      hmac.update(signature)
  
      puts "hmac: :  #{hmac}"
      puts Rho::RhoSupport.url_encode(Base64.encode64("#{hmac.digest}\n"))
end
My Build.yml :
android:
  manifest_template: "AndroidManifest.erb"
#android_title: 0
  version: "2.3.1"
  extensions:
    - screenorientation
    - coreapi
    - hmac
    - digest
    - digest-sha2
  capabilities:
    - hardware_acceleration
capabilities:
  - gps
  - camera
  - network_state
  - Network
  - hardware_acceleration

The above seems to work fine on Rho Simulator but does not work on android device.What can be the problem ??
My current version of Rhodes is 4.1.1 and of Ruby is 1.9.1

Please note that i need to make it work for both android and iOS devices

Any help is appreciated

Thanks
Siddhant

Please register or login to post a reply

3 Replies

E Evgeny Vovchenko

Hello,

Here is the doc:
Rhomobile | Ruby Native Extensions

OpenSSL – based libraries
openssl, ezcrypto
Add to build.yml:
extensions: ["openssl.so", "openssl", "digest-sha2", "ezcrypto"] digest-sha2
Add to build.yml:
extensions: ["openssl.so", "openssl", "digest", "digest-sha2" ]

openssl.so is native c-library and should be included in extensions list to use openssl-base libraries

Try it please
Regards,
Evgeny.

H Hector Meza

Evgeny, do we have a working sample? Thank you

HM

S Siddhant Wadhera

Guys any help is appreciated

thanks
Siddhant

CONTACT
Can’t find what you’re looking for?