Я создаю пользовательский класс EncryptionInterceptor
, но я не могу зашифровать идеальные данные, любая помощь оценит, это спасет мои дни
вот мой код
public class EncryptionInterceptor implements Interceptor {
private static final String TAG = EncryptionInterceptor.class.getSimpleName();
private static final boolean DEBUG = true;
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
RequestBody oldBody = request.body();
Buffer buffer = new Buffer();
oldBody.writeTo(buffer);
String strOldBody = buffer.readUtf8();
//MediaType mediaType = MediaType.parse("text/plain; charset=utf-8");
MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
String strNewBody = encrypt(strOldBody);
RequestBody body = RequestBody.create(mediaType, strNewBody);
request = request.newBuilder()/*.header("Content-Type", body.contentType().toString()).header("Content-Length", String.valueOf(body.contentLength()))*/
.method(request.method(), body).build();
return chain.proceed(request);
}