Crypto Functions

This chapter introduces the crypto macros provided by Surreal ORM. The crypto macros are used for cryptographic operations such as password hashing and comparison.

Table of Contents

argon2::compare!()

The argon2::compare!() macro compares two values using the Argon2 hashing algorithm. It has the following syntax:

#![allow(unused)]
fn main() {
let result = argon2::compare!("Oyelowo", "Oyedayo");
}

The argon2::compare!() macro generates the following SQL query:

crypto::argon2::compare('Oyelowo', 'Oyedayo')

argon2::generate!()

The argon2::generate!() macro generates a hash value using the Argon2 hashing algorithm. It has the following syntax:

#![allow(unused)]
fn main() {
let result = argon2::generate!("Oyelowo");
}

The argon2::generate!() macro generates the following SQL query:

crypto::argon2::generate('Oyelowo')

pbkdf2::compare!()

The pbkdf2::compare!() macro compares two values using the PBKDF2 hashing algorithm. It has the following syntax:

#![allow(unused)]
fn main() {
let result = pbkdf2::compare!("hash_value", "password");
}

The pbkdf2::compare!() macro generates the following SQL query:

crypto::pbkdf2::compare('hash_value', 'password')

pbkdf2::generate!()

The pbkdf2::generate!() macro generates a hash value using the PBKDF2 hashing algorithm. It has the following syntax:

#![allow(unused)]
fn main() {
let result = pbkdf2::generate!("password");
}

The pbkdf2::generate!() macro generates the following SQL query:

crypto::pbkdf2::generate('password')

scrypt::compare!()

The scrypt::compare!() macro compares two values using the scrypt hashing algorithm. It has the following syntax:

#![allow(unused)]
fn main() {
let result = scrypt::compare!("hash_value", "password");
}

The scrypt::compare!() macro generates the following SQL query:

crypto::scrypt::compare('hash_value', 'password')

scrypt::generate!()

The scrypt::generate!() macro generates a hash value using the scrypt hashing algorithm. It has the

following syntax:

#![allow(unused)]
fn main() {
let result = scrypt::generate!("password");
}

The scrypt::generate!() macro generates the following SQL query:

crypto::scrypt::generate('password')

bcrypt::compare!()

The bcrypt::compare!() macro compares two values using the bcrypt hashing algorithm. It has the following syntax:

#![allow(unused)]
fn main() {
let result = bcrypt::compare!("hash_value", "password");
}

The bcrypt::compare!() macro generates the following SQL query:

crypto::bcrypt::compare('hash_value', 'password')

bcrypt::generate!()

The bcrypt::generate!() macro generates a hash value using the bcrypt hashing algorithm. It has the following syntax:

#![allow(unused)]
fn main() {
let result = bcrypt::generate!("password");
}

The bcrypt::generate!() macro generates the following SQL query: