"use strict";

module.exports.makeCppFileTemplateAndroid = data => {
  return "\n  #include \"crypto.hpp\"\n  #include <string>\n  #include \"encrypt.h\"\n\n  using namespace std;\n\n  Crypto::Crypto() {\n\n  }\n\n\n  std::string Crypto::getJniJsonStringyfyData(string key) {\n    std::string jsonStringyfyData= \"".concat(data, "\";\n      string hash;\n      int len=jsonStringyfyData.length();\n      char cahrtot[len+1];\n      strcpy(cahrtot,jsonStringyfyData.c_str());\n      hash=SHA256(cahrtot);\n      string halfString=hash.substr(hash.length()/2);\n      if(key==halfString)\n      {\n        return jsonStringyfyData;\n      }\n      else\n      {\n          return \"\";\n      }\n    \n  }\n  ");
};

module.exports.makeHppFileTemplateAndroid = () => {
  return "\n  #ifndef crypto_hpp\n  #define crypto_hpp\n\n  #include <stdio.h>\n  #include <string>\n  using namespace std;\n\n  class Crypto {\n  public:Crypto();\n    string getJniJsonStringyfyData(string key);\n  };\n  #endif\n  ";
};

module.exports.makeCryptographicModuleTemplateAndroid = key => {
  return "\n  package com.rnkeys;\n  import android.content.Context;\n  import android.content.res.Resources;\n  import android.util.Log;\n  \n  import androidx.annotation.NonNull;\n  \n  import com.facebook.react.bridge.Promise;\n  import com.facebook.react.bridge.ReactApplicationContext;\n  import com.facebook.react.bridge.ReactContextBaseJavaModule;\n  import com.facebook.react.bridge.ReactMethod;\n  \n  import org.json.JSONException;\n  import org.json.JSONObject;\n\n  import java.lang.reflect.Field;\n  import java.util.HashMap;\n  import java.util.Map;\n  \n  public class KeysModule extends ReactContextBaseJavaModule {\n      public static final String REACT_CLASS = \"Keys\";\n      public static final String PRIVATE_KEY = \"".concat(key, "\";\n      private static ReactApplicationContext reactContext;\n  \n      static private JSONObject jniData;\n  \n      KeysModule(ReactApplicationContext context) {\n          super(context);\n          reactContext = context;\n      }\n  \n  \n      @ReactMethod\n      static public void secureFor(String key,Promise promise) {\n          String value=getSecureFor(key);\n          promise.resolve(value);\n      }\n  \n  \n      static public String getSecureFor(String key) {\n  \n          try {\n              if (jniData == null)\n                  jniData = new JSONObject(CLibController.getInstance().getJniJsonStringyfyData(PRIVATE_KEY));\n  \n              if (jniData.has(key)) {\n                  return jniData.getString(key);\n              }\n          } catch (Exception ignore) {\n              return \"\";\n          }\n          return \"\";\n      }\n  \n      @ReactMethod\n      public void sampleMethod(Promise promise) {\n         promise.resolve(\"I am sample Methods\");\n      }\n  \n      @Override\n      public String getName() {\n          return REACT_CLASS;\n      }\n\n      @Override\n      public Map<String, Object> getConstants() {\n        final Map<String, Object> constants = new HashMap<>();\n  \n        try {\n          Context context = getReactApplicationContext();\n          int resId = context.getResources().getIdentifier(\"build_config_package\", \"string\", context.getPackageName());\n          String className;\n          try {\n            className = context.getString(resId);\n          } catch (Resources.NotFoundException e) {\n            className = getReactApplicationContext().getApplicationContext().getPackageName();\n          }\n          Class clazz = Class.forName(className + \".BuildConfig\");\n          Field[] fields = clazz.getDeclaredFields();\n          for(Field f: fields) {\n            try {\n              constants.put(f.getName(), f.get(null));\n            }\n            catch (IllegalAccessException e) {\n              Log.d(\"ReactNative\", \"ReactConfig: Could not access BuildConfig field \" + f.getName());\n            }\n          }\n        }\n        catch (ClassNotFoundException e) {\n          Log.d(\"ReactNative\", \"ReactConfig: Could not find BuildConfig class\");\n        }\n  \n        return constants;\n      }\n    }  \n  ");
};
//# sourceMappingURL=keysFilesTemplateAndroid.js.map