Function validate_header

Source
pub fn validate_header(data: &[u8], data_type: DataType) -> bool
Expand description

Only validate the header to make sure it is valid. Used to quickly determine if the data comes from the library.

§Arguments

  • data - The data to verify.
  • data_type - The type of the data.

§Returns

true if the header is valid, false if it is not.

§Example

use devolutions_crypto::DataType; use devolutions_crypto::ciphertext::{encrypt, CiphertextVersion}; use devolutions_crypto::utils::{generate_key, validate_header};

let key = generate_key(32); let ciphertext: Vec = encrypt(b“test“, &key, CiphertextVersion::Latest).unwrap().into();

assert!(validate_header(&ciphertext, DataType::Ciphertext); assert!(!validate_header(&ciphertext, DataType::PasswordHash); assert!(!validate_header(&key, DataType::Ciphertext);