Decodes four bytes from array source and writes the resulting bytes (up to three of them) to destination . The source and destination arrays can be manipulated anywhere along their length by specifying srcOffset and destOffset . This method does not check to
(byte[] source, int srcOffset,
byte[] destination, int destOffset, byte[] decodabet)
| 373 | * @since 1.3 |
| 374 | */ |
| 375 | private static int decode4to3(byte[] source, int srcOffset, |
| 376 | byte[] destination, int destOffset, byte[] decodabet) { |
| 377 | // Example: Dk== |
| 378 | if (source[srcOffset + 2] == EQUALS_SIGN) { |
| 379 | int outBuff = |
| 380 | ((decodabet[source[srcOffset]] << 24) >>> 6) |
| 381 | | ((decodabet[source[srcOffset + 1]] << 24) >>> 12); |
| 382 | |
| 383 | destination[destOffset] = (byte) (outBuff >>> 16); |
| 384 | return 1; |
| 385 | } else if (source[srcOffset + 3] == EQUALS_SIGN) { |
| 386 | // Example: DkL= |
| 387 | int outBuff = |
| 388 | ((decodabet[source[srcOffset]] << 24) >>> 6) |
| 389 | | ((decodabet[source[srcOffset + 1]] << 24) >>> 12) |
| 390 | | ((decodabet[source[srcOffset + 2]] << 24) >>> 18); |
| 391 | |
| 392 | destination[destOffset] = (byte) (outBuff >>> 16); |
| 393 | destination[destOffset + 1] = (byte) (outBuff >>> 8); |
| 394 | return 2; |
| 395 | } else { |
| 396 | // Example: DkLE |
| 397 | int outBuff = |
| 398 | ((decodabet[source[srcOffset]] << 24) >>> 6) |
| 399 | | ((decodabet[source[srcOffset + 1]] << 24) >>> 12) |
| 400 | | ((decodabet[source[srcOffset + 2]] << 24) >>> 18) |
| 401 | | ((decodabet[source[srcOffset + 3]] << 24) >>> 24); |
| 402 | |
| 403 | destination[destOffset] = (byte) (outBuff >> 16); |
| 404 | destination[destOffset + 1] = (byte) (outBuff >> 8); |
| 405 | destination[destOffset + 2] = (byte) (outBuff); |
| 406 | return 3; |
| 407 | } |
| 408 | } // end decodeToBytes |
| 409 | |
| 410 | |
| 411 | /** |