Encode integer array as base64 int64 string (allocatable output)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | values(:) | |||
| integer, | intent(in) | :: | n | |||
| character(len=:), | intent(out), | allocatable | :: | output |
subroutine encode_int64_base64_alloc(values, n, output) !! Encode integer array as base64 int64 string (allocatable output) use iso_fortran_env, only: int8, int64 implicit none integer, intent(in) :: values(:) integer, intent(in) :: n character(:), allocatable, intent(out) :: output integer(int8), allocatable :: bytes(:) integer(int64) :: ival64 integer :: i, j, nbytes nbytes = n * 8 allocate(bytes(nbytes)) do i = 1, n ival64 = int(values(i), int64) do j = 0, 7 bytes((i-1)*8 + j + 1) = & int(iand(ishft(ival64, -j*8), int(255, int64)), int8) end do end do call base64_encode_bytes(bytes, nbytes, output) deallocate(bytes) end subroutine encode_int64_base64_alloc