Decode to hex

    0

    0

    Giovanny Gongora

    Codiga's Rust Recipes

    Decode using HEXUPPER

    use data_encoding::{HEXUPPER, DecodeError};
    
    fn main() -> Result<(), DecodeError> {
      let original = b"The quick brown fox jumps over the lazy dog.";
      let expected = "54686520717569636B2062726F776E20666F78206A756D7073206F76\
      657220746865206C617A7920646F672E";
      let encoded = HEXUPPER.encode(original);
      assert_eq!(encoded, expected);
      let decoded = HEXUPPER.decode(&encoded.into_bytes())?;
      assert_eq!(&decoded[..], &original[..]);
      Ok(())
    }
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.