Package: databridges_nacl_wrapper
Databridges Python NaCl Wrapper LibraryDatabridges NACL wrapper gives you a simple write and read function using implementation of the secretbox encryption standard defined in NaCl.Databridges NACL wrapper is available forJavaScriptNodeJSC#PythonJava for AndroidiOS SwiftThe above wrappers can be used to send encrypted messages between them.The Databridges NACL wrapper for Python Language binding usesPyNaClto deliver implementation of the secretbox encryption standard defined in NaCl.Usage OverviewThe following topics are covered:Supported platformsInstallation.InitializationGlobal ConfigurationHow to use with Databridges Python LibraryChange LogLicenseSupported platformsSupports Python versions  +3.6Installation.You can use pip package manager to install the package.pip3installdatabridges_nacl_wrapperInitializationfromdatabridges_nacl_wrapperimportdatabridges_nacl_wrappersecretData=databridges_nacl_wrapper()Global ConfigurationRequiredThe following is the required properties before using to dataBridges NaCl wrapper.secretData.secret='32 char alphanumeric string';PropertiesDescriptionsecret(string)32 char alpha numeric string. NaCl encryption secret.Encrypt dataTo encrypt data using NaCl, databridges wrapper exposes a method namedwrite, This will return encrypted data if successful else it will throw error.write()try:encData=secretData.write("Your Data..");print('Encrypted:',encData);exceptExceptionaserr:print('Errors:',err.source,err.code,err.message);ParameterDescriptiondata(string)datato be encrypted.Return ValuesDescriptionstringEncrypted  string.Exceptions:SourceCodeDescriptionDBLIB_NACL_WRAPPERINVALID_SECRETsecretis not set with the wrapper instance.DBLIB_NACL_WRAPPERINVALID_DATAIfdatais not passed to the function.DBLIB_NACL_WRAPPERNACL_EXCEPTIONExceptions generated by NaCl library.Decrypt dataTo decrypt data using NaCl, databridges wrapper exposes a method namedread, This will return decrypted data if successful else it will throw error.read()try:decData=secretData.read("<Encrypted data.>")print('Decrypted:',decData);exceptExceptionaserr:print("Errors:",err.source,err.code,err.message)ParameterDescriptiondata(string)datato be encrypted.Return ValuesDescriptionstringEncrypted  string.Exceptions:SourceCodeDescriptionDBLIB_NACL_WRAPPERINVALID_SECRETsecretis not set with the wrapper instance.DBLIB_NACL_WRAPPERINVALID_DATAIfdatais not passed to the function ORdatais not a valid encrypted string.DBLIB_NACL_WRAPPERNACL_EXCEPTIONExceptions generated by NaCl library.DBLIB_NACL_WRAPPERNACL_DECRYPT_FAILEDIf decryption fails due to invalid secret or manipulated data.How to use with Databridges Python LibraryBelow code shows how to integrate the NaCl wrapper with the Databridges library. After initialize you can use the wrapper library to encrypt and decrypt the data when publishing and receiving events.# Initialize both databridges-sio-client-lib and databridges-nacl-wrapperfromdatabridges_sio_client_libimportdBridgesfromdatabridges_sio_client_lib.exceptionsimportdBErrorfromdatabridges_nacl_wrapperimportdatabridges_nacl_wrapperdbridge=dBridges()secretData=databridges_nacl_wrapper()secretData.secret="Your32 char secret.";# .... Your databridges code comes here.# On Subscription success event.asyncdefon_SubscribeChannel(payload,metadata):try:# Encrypt data to publishencData=secretData.write('Your Data..')awaitself.subscribeChannel.publish('eventName',encData,1)exceptExceptionaserr:print("Error: ",err.source,err.code,err.message)self.subscribeChannel.bind("dbridges:subscribe.success",on_SubscribeChannel)# On payload Received event.asyncdefon_EventReceived(payload,metadata):try:decData=secretData.read(payload)print('Decrypted:',decData);exceptExceptionaserr:print("Error: ",err.source,err.code,err.message)self.subscribeChannel.bind("eventName",on_EventReceived)Change LogChange log: Changes in the recent versionsLicenseDataBridges NaCl Wrapper is released under theMIT license.Copyright 2022 Optomate Technologies Private Limited.

    Permission is hereby granted, free of charge, to any person obtaining
    a copy of this software and associated documentation files (the
    "Software"), to deal in the Software without restriction, including
    without limitation the rights to use, copy, modify, merge, publish,
    distribute, sublicense, and/or sell copies of the Software, and to
    permit persons to whom the Software is furnished to do so, subject to
    the following conditions:

    The above copyright notice and this permission notice shall be
    included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
    LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
    OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.