lib/mqttbridge/YalgaarInitModule.rb in yalgaar-1.0.1 vs lib/mqttbridge/YalgaarInitModule.rb in yalgaar-1.0.2

- old
+ new

@@ -1,11 +1,11 @@ #@fileName <YalgaarInitModule.rb> #@brief - <Initialize all varialbes and common methods> # #Revision Log: -# v1.0.1 : Aug 4, 2016 INITIAL OF PROGRAMMER - REVISION DETAIL_1 <- THIS IS THE LATEST REVISION +# v1.0.2 : Aug 4, 2016 INITIAL OF PROGRAMMER - REVISION DETAIL_1 <- THIS IS THE LATEST REVISION #Description: #YalgaarInitModule contents methods and variables and enum.. # #@bug Known Issues: # 1. ISSUE NAME - NONE @@ -74,10 +74,11 @@ YALGAAR_122=122, YALGAAR_123=123, YALGAAR_150=150, YALGAAR_NO_SERVER_CONNECTION=151, YALGAAR_INVALID_AES_TYPE=152, + YALGAAR_INVALID_AES_KEY_LENGTH=153, YALGAAR_MAX=200 ] #init(message); #@brief - <To init as given length> #@param <Length> : <length for how long uuid generating> @@ -99,11 +100,12 @@ @@lSubCallback=nil @@lPresenceCallback=nil @@lHistoryCallback=nil @@lChannelList=nil @@lUserList=nil - @@host='192.168.60.6' + @@host='api.yalgaar.io' + @@isEncrpt=nil end end module YalgaarApis include MQTT @@ -233,16 +235,18 @@ def encryption(msg) begin cipher = OpenSSL::Cipher.new(@@aesType) cipher.encrypt() cipher.key = @@aesSecretKey + cipher.iv = @@aesSecretKey[0..15] crypt = cipher.update(msg) + cipher.final() crypt_string = (Base64.encode64(crypt)) return crypt_string rescue Exception => exc - puts ("Message for the encryption log file for message #{msg} = #{exc.message}") + puts "Message for the encryption log file for message #{msg} = #{exc.message}" end + end #decryption(channel); #@brief - <To decryption> #@param <channel> : <length for how long uuid generating> @@ -250,10 +254,11 @@ def decryption(msg) begin cipher = OpenSSL::Cipher.new(@@aesType) cipher.decrypt() cipher.key = @@aesSecretKey + cipher.iv = @@aesSecretKey[0..15] tempkey = Base64.decode64(msg) crypt = cipher.update(tempkey) crypt << cipher.final() return crypt rescue Exception => exc @@ -322,9 +327,11 @@ errMessage="Invalid IsSecure Flag." when YALGAAR_NO_SERVER_CONNECTION errMessage="No server connection found." when YALGAAR_INVALID_AES_TYPE errMessage="Invalid AES Type." + when YALGAAR_INVALID_AES_KEY_LENGTH + errMessage="Invalid AES key length." else errMessage="Success" end errMessage end