Skip to main content

decode_base64

Function decode_base64 

Source
pub fn decode_base64(src: &[u8]) -> Result<Vec<u8>, Error>
Expand description

Decode unpadded standard Base64, the alphabet PHC strings use.

Same dispatch as from_base64. The whole of src must be alphabet characters; leftover junk is Error::DecodingFail, unlike the C’s from_base64, which stops at the first non-alphabet byte and leaves the tail for the caller. PHC fields have no tail.

use argon2_rust::decode_base64;

assert_eq!(decode_base64(b"c29tZXNhbHQ")?, b"somesalt");

§Errors

Error::DecodingFail if src is not entirely valid unpadded Base64, or Error::MemoryAllocationError if the output buffer cannot be allocated.