You should not be cluttering the code archives with stuff that is not complete. The code as it is does not really help much. Next time post it in its corresponding programming section and ask for help there. Once you figure it out, post it here.
just to help you out, I figured it out:
Local toen:String = Input$("> ")
encript(toen)
decript()
Function encript:Int(toencrypt:String)
Local writer:TStream = WriteFile("encrypted.txt")
For Local a:Int = 1 To Len(toencrypt) Step 1
Local b:String = Mid(toencrypt,a,1)
Local c:Int = Asc(b)
Local d:String = Bin(c)
For Local e:Int = 1 To Len(d) Step 1
Local f:String = Mid(d,e,1)
Local l:Int = Asc(f)
Local g:String = Hex(l)
For Local h:Int = 1 To Len(g) Step 1
Local i:String = Mid(g,h,1)
Local j:Int = Asc(i)
Local k:String = Bin(j)
WriteLine writer,k
Next
Next
Next
CloseFile(writer)
Return 1
End Function
Function deCript()
Local reader:TStream = ReadFile("encrypted.txt")
If reader = Null Print "unable To OpenFile"
Local str:String = Null
Local str2:String = Null
Local str3:String = Null
While Not Eof(reader)
Local s:String = ReadLine(reader)
Local a:Int = binStrToInt(s)
If str.length < 8
str :+Chr(a)
Else
str = Chr(a)
EndIf
If str.length = 8
If str2.length < 32
str2 :+ Chr(hexStrToInt(str))
Else
str2 = Chr(hexstrToInt(str))
EndIf
If str2.length = 32
str3:+ Chr(binStrToInt(str2))
EndIf
EndIf
Wend
Print str3
CloseFile(reader)
End Function
Function binStrToInt:Int(s:String)
Local v:Int = 0
For Local i:Int = 1 To s.length
v :| (Int(Mid$(s,i,1)) Shl (32-i))
Next
Return v
End Function
Function hexStrToInt:Int(s:String)
Local v:Int = 0
For Local i:Int = 1 To s.length
Local c:String = Mid$(s,i,1)
Local n:Int
If Asc(c) > 64
n = Asc(c) - 55
Else
n = Int(c)
EndIf
v :| (n Shl ((8-i)*4))
Next
Return v
End Function
|