Wednesday, December 11, 2019

decrypt elliptic curve hack folder code fortran



Program that decodes a message in Fortran


program Program2

implicit none

INTEGER, DIMENSION(2,2) :: M, M2, M3
INTEGER :: B(32)
INTEGER :: row,col,max_rows,max_cols, Det, i, n, a
max_rows = 2
max_cols = 2

open(11, file = 'Data3.txt')

DO row = 1,max_rows
  READ(11,*) (M(row,col),col=1,max_cols)
END DO

!Finding the inverse of a 2x2 matrix and reassigning.
M2(1,1) = M(2,2)
M2(2,2) = M(1,1)
M2(1,2) = -M(1,2)
M2(2,1) = -M(2,1)

! Could not get determinant function to yield correct answer (calc by hand)
M3 = M2/-1
print*, M3
print*, Det

open(11, file = 'Data3.txt')
i = a

do i = 1, 16
    read(11,*) n
    print*, n
enddo

close(11)
end program Program2

! Determinant function for a 2x2 matrix
function Determinant(M2) result(Det)

   implicit none
   INTEGER, DIMENSION(2,2) :: M, M2, M3
   INTEGER :: B(32)
   INTEGER :: row,col,max_rows,max_cols, Det, i, n, a

   Det = M2(1,1)*M2(2,2) - M2(1,2)*M2(2,1)

end function Determinant

No comments: