From 556c62a21c09ba36254d9a9ebdacce7587a5954e Mon Sep 17 00:00:00 2001 From: Jeffrey Armstrong Date: Fri, 1 Jul 2022 13:35:20 -0400 Subject: Added a commandline driven crypt module for messy, old systems. --- captain/cryptcl.f90 | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 captain/cryptcl.f90 diff --git a/captain/cryptcl.f90 b/captain/cryptcl.f90 new file mode 100644 index 0000000..429da26 --- /dev/null +++ b/captain/cryptcl.f90 @@ -0,0 +1,44 @@ +module m_crypt +implicit none + +contains + + function hash(phrase) + use utilities, only: get_one_line_output_shell_command + implicit none + + character(len=*), intent(in)::phrase + character(len=:), pointer::hash + + character(len=256)::tempout + + call get_one_line_output_shell_command('mkpasswd -m sha-512 "'//trim(phrase)//'"', & + tempout) + + allocate(character(len=len_trim(tempout)) :: hash) + hash = trim(tempout) + + end function hash + + function verify_hash(phrase, hashed) + use utilities, only: get_one_line_output_shell_command + implicit none + + character(len=*), intent(in)::phrase, hashed + logical::verify_hash + + character(len=256)::tempout + character(32)::salt + integer::i + + i = index(hashed(4:len_trim(hashed)), "$") + salt = hashed(4:i+2) + + call get_one_line_output_shell_command('mkpasswd -m sha-512 -S '//trim(salt)//' "'//trim(phrase)//'"', & + tempout) + + verify_hash = (trim(tempout) == trim(hashed)) + + end function verify_hash + +end module m_crypt \ No newline at end of file -- cgit v1.2.3