Skip to content
Snippets Groups Projects
Commit 3c10dc86 authored by dali662d's avatar dali662d
Browse files

Upload New File

parent 37c62976
Branches
No related tags found
No related merge requests found
module passcode_mod
implicit none
private
public :: keineLZ, langGenug, kreativ, sicherGenug
contains
function keineLZ (pc)
logical :: keineLZ
character(len = 20), intent(in) :: pc
integer :: i
keineLZ = .true.
aussen: do i = 1, len_trim(pc)
if (pc(i:i) == " ") then
keineLZ = .false.
exit
end if
end do aussen
end function keineLZ
function sicherGenug (pc)
logical :: sicherGenug
character(len = 20), intent(in) :: pc
logical :: gross = .false., klein = .false., zahl = .false.
integer :: i
do i = 1, len_trim(pc)
select case (ichar(pc(i:i)))
case(ichar("0") : ichar("9"))
zahl = .true.
case(ichar("A") : ichar("Z"))
gross = .true.
case(ichar("a") : ichar("z"))
klein = .true.
case default
end select
if (zahl .and. gross .and. klein) exit ! nicht dringend notwendig
end do
sicherGenug = zahl .and. gross .and. klein
end function sicherGenug
! alternative Funktion -> IF Schleife und ASCII anders
FUNCTION sicherGenug_alt(pw)
CHARACTER(*),INTENT(IN):: pw
LOGICAL:: sicherGenug_alt
INTEGER:: i, ascii
LOGICAL:: gross, klein, ziffer
gross = .false.
klein = .false.
ziffer = .false.
DO i=1, LEN(pw)
ascii = IACHAR(pw(i:i))
IF(ascii >= 65 .AND. ascii <= 90) THEN
gross = .true.
ELSE IF(ascii >= 97 .AND. ascii <= 122) THEN
klein = .true.
ELSE IF(ascii >= 48 .AND. ascii <= 57)THEN
ziffer = .true.
END IF
END DO
sicherGenug_alt = ziffer .AND. klein .AND. gross
END FUNCTION sicherGenug_alt
function langGenug (pc)
logical :: langGenug
character(len = 20), intent(in) :: pc
if (len(trim(pc)) >= 8) then
langGenug = .true.
else
langGenug = .false.
end if
end function langGenug
function kreativ (pc)
implicit none
logical :: kreativ
character(len = 20), intent(in) :: pc
character(len = 20) :: help
integer :: ios
kreativ = .true.
open (unit = 30, iostat = ios, file = "bekanntepasswoerter.txt", status = "old", action = "read")
if (ios == 0) then
do
read(30,*,iostat = ios) help
if(ios /= 0) exit
if(pc == help) then
kreativ = .false.
exit
end if
end do
else
write(*,*) "Datei konnte nicht korrekt geoeffnet werden!"
end if
close (30)
end function kreativ
end module passcode_mod
program passcodecheck
use passcode_mod
implicit none
character(len = 20) :: pc, pc2
logical :: ok = .true.
do
do
write(*,*) "Gebe dein Passwort in Anfuehrungszeichen ein."
read(*,*) pc
write(*,*) "Wiederhole das Passwort"
read(*,*) pc2
if (pc == pc2) exit
write(*,*) "Die eingegebenen Passwoerter sind nicht gleich."
end do
if (.not. keineLZ(pc)) then
write(*,*) "Es sind Leerzeichen in der Mitte."
ok = .false.
end if
if (.not. langGenug(pc)) then
write(*,*) "Das Passwort ist nicht lang genug."
ok = .false.
end if
if (.not. sicherGenug(pc)) then
write(*,*) "Es fehlen Gross-, Kleinbuchstaben oder Zahlen."
ok = .false.
end if
if (.not. kreativ(pc)) then
write(*,*) "Das Passwort ist nicht sonderlich kreativ."
ok = .false.
end if
if (ok) then
write(*,*) "Dein Passwort ist ok."
exit
end if
end do
end program passcodecheck
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment