Network Wizard for VHDL Test Benches
Base16/32/64

Base16, Base32, and Base64 data encoding/decoding

This library provides functions for Base16, Base32, and Base64 data encoding and decoding according to RFC 4648.

Functionality

  • Perform Base16/32/64 encoding of data arrays
  • Perform Base16/32/64 decoding of encoded data arrays


More details in nw_base_pkg

Example use

Include the libraries:

library nw_codec;
context nw_codec.nw_codec_context;

Data to be encoded must be in 8bit format.

v_data := f_str_2_slv_arr("Blue shoes"); -- data array to be encoded
v_len := f_base_enc_len(v_data, BASE64); -- get length of encoded data (v_len is now 16)
v_encoded(0 to v_len - 1) := f_base_enc(v_data, BASE64); -- v_encoded is now "Qmx1ZSBzaG9lcw=="
v_len := f_base_enc_len(v_data, BASE32); -- get length of encoded data (v_len is now 16)
v_encoded(0 to v_len - 1) := f_base_enc(v_data, BASE32); -- v_encoded is now "IJWHKZJAONUG6ZLT"

Decode the encoded data:

v_dlen := f_base_dec_len(v_encoded(0 to v_len - 1)); -- get length od decoded data (v_dlen is now 10)
v_decoded(0 to v_dlen - 1) := f_base_dec(v_encoded(0 to v_len - 1)); -- v_decoded is now equal to v_data

See further examples in the test bench nw_codec_tb.vhd.