Skip to content

Instantly share code, notes, and snippets.

@dkomanov
Created October 27, 2022 10:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dkomanov/52e8b825e63c2b9144a277f9e8c611d1 to your computer and use it in GitHub Desktop.
Save dkomanov/52e8b825e63c2b9144a277f9e8c611d1 to your computer and use it in GitHub Desktop.
#[no_mangle]
pub extern "system" fn decodeConfigSliceUrlSafe2(
env: JNIEnv,
_class: JClass,
payload: jbyteArray,
size: usize,
output: *mut u8,
output_size: usize,
) -> usize {
let arr = env.get_byte_array_elements(
payload,
ReleaseMode::NoCopyBack,
).unwrap();
let (input_slice, output_slice) = unsafe {
(
std::slice::from_raw_parts(arr.as_ptr() as *const u8, size),
std::slice::from_raw_parts_mut(output, output_size),
)
};
return base64::decode_config_slice(
input_slice,
base64::URL_SAFE_NO_PAD,
output_slice,
).unwrap();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment