Implementation of basic crypto functions