Friday, 24 December 2021

Android Retrofit Parameter Encryption and Decryption SHA256

In my application I am using webservices using Retrofit. I have to Encrypt Field (parameter) in Request and Decrypt it on PHP Server.

I have to Encrypt and Decrypt version parameter.

Here is my RetroApi.java

public interface RetroApi {

    @FormUrlEncoded
    @POST("index.php/api/check-version")
    Call<String> getCheckVersion(@Field("version") String version, @Field("app") String app);
    
}

Creating instance of RetroApi.java

RetroApi retroApi;

HttpLoggingInterceptor logging = new HttpLoggingInterceptor();

logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient httpClient = new OkHttpClient.Builder().addInterceptor(logging).build();
Gson gson = new GsonBuilder().setLenient().create();
Retrofit retrofit = new Retrofit.Builder().baseUrl(RetroApp.BASE_URL).addConverterFactory(ScalarsConverterFactory.create())
        .addConverterFactory(GsonConverterFactory.create(gson)).client(httpClient).build();

retroApi = retrofit.create(RetroApi.class);

Here is the Webservice call

Call<String> getResult = retroApi.getCheckVersion(Constants.SP_APP_VERSION, Constants.SP_APP_NAME);
    getResult.enqueue(new Callback<String>() {
        @Override
        public void onResponse(Call<String> call, Response<String> response) {
             
        }

        @Override
        public void onFailure(Call<String> call, Throwable t) {
            t.printStackTrace();
        }
    });

Please assist me to accomplish this.



from Android Retrofit Parameter Encryption and Decryption SHA256

No comments:

Post a Comment