decrypting help!!

Blitz3D Forums/Blitz3D Programming/decrypting help!!

blade007(Posted 2008) [#1]
There is something wrong with my program. When it tries to decode the encoded password, it comes out in numbers instead of letters. Help please?

Graphics 800,600,8,2
Type letter
	Field txt$,enc
End Type
AppTitle "IRS system"
Print "Login Screen"
Print "password required!"
If FileType("answer.txt") = 1


	Print "making pass"
	file = OpenFile("answer.txt")
		Print "Step 1 of 2 reading pass..."
		While Not Eof(file)
			letter.letter = New letter
			letter\txt$ = ReadByte(file)
		Wend
	CloseFile(file)
	
	DeleteFile("encoding.txt")
	mydoom = WriteFile("encoding.txt")
		Print "Step 2 of 2 encoding pass..."
		For letter.letter = Each letter
			letter\enc = Asc(letter\txt$)
			key = Rand(1,122)
			letter\enc = letter\enc + key
			WriteLine(mydoom ,key)
			WriteLine(mydoom ,letter\enc)
			Delete letter
		Next
		CopyFile("answer.txt","pass.txt")
		DeleteFile("answer.txt")
		End
EndIf
If FileType("pass.txt") <> 1
	Print "type and save password as pass.txt in this folder!"
	; save answer key as answer.txt ^^
	Print "press any key to continue!"
	WaitKey
	End
EndIf

Delay 2000
Print "reading encoded pass..."
answerkey = OpenFile("encoding.txt")
While Not Eof(answerkey )
	key = ReadLine(answerkey )
	preletter = ReadLine(answerkey )
	preletter = preletter-key
	letters$ = Chr$(preletter)
	letter.letter = New letter
		letter\txt$ = letters$
		Write letters$
Wend
Print ""
Delay 2000
CloseFile(answerkey )
password = OpenFile("pass.txt")
	Print "checking your pass..."
	Print ReadLine(password)
	SeekFile(password,0)
	
	For letter.letter = Each letter
		passletter$ = ReadByte(password)
		Write passletter$
		If passletter$ <> letter\txt$
		incorrect = True
		EndIf
	Next
	
CloseFile(password)
Print ""
Delay 2000
If incorrect = True
	Print "Access Denied!!"
	Print "The IRS has taken your house, your dog, your money, and your wife, because you have tried"
	Print "to hack into their security system!"
Else
	Print "Access Granted!!"
	Print "WTF!! u hacked into the IRS, and stopped their nagging about you paying ur taxes!!"
EndIf
WaitKey
End



H. T. U.(Posted 2008) [#2]
ReadLine returns a string, so the variable which is assigned that data needs to be a string variable.