20 Replies Latest reply on Oct 1, 2014 5:58 AM by Siddhant Wadhera

    HMAC:SHA256 giving Error on Device

    Siddhant  Wadhera

      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