aboutsummaryrefslogtreecommitdiff
path: root/captain
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeff@approximatrix.com>2022-07-01 13:35:20 -0400
committerJeffrey Armstrong <jeff@approximatrix.com>2022-07-01 13:35:20 -0400
commit556c62a21c09ba36254d9a9ebdacce7587a5954e (patch)
tree7b8c525c1d7690afc53ed2d8f76ed9a5b84b454d /captain
parent534149f29466e5e7b20097612b44114ba60ce9b5 (diff)
downloadlevitating-556c62a21c09ba36254d9a9ebdacce7587a5954e.tar.gz
levitating-556c62a21c09ba36254d9a9ebdacce7587a5954e.zip
Added a commandline driven crypt module for messy, old systems.
Diffstat (limited to 'captain')
-rw-r--r--captain/cryptcl.f9044
1 files changed, 44 insertions, 0 deletions
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