Code archives/Algorithms/Tough Binary Encryption

This code has been declared by its author to be Public Domain code.

Download source code

Tough Binary Encryption by Luke1112010
If anybody can make a decoder for this, I will give you a cuban cigar. Just Kidding! Im new to this and this is my first BMAX code. I could not decrypt this, so I will let you guys.
toen$ = Input$("> ")
encbinenc(toen$)
Function encbinenc(toencrypt$)
writer = WriteFile("encrypted.txt")
For a = 1 To Len(toencrypt$) Step 1
b$ = Mid(toencrypt$,a,1)
c = Asc(b$)
d$ = Bin(c)
For e = 1 To Len(d$) Step 1
	f$ = Mid(d,e,1)
	l = Asc(f$)
	g$ = Hex(l)
	For h = 1 To Len(g$) Step 1
		i$ = Mid(g$,h,1)
		j = Asc(i$)
		k$ = Bin(j)
		WriteLine writer,k
	Next
Next
Next
CloseFile(writer)
reader = ReadFile("encrypted.txt")
While Not Eof(reader)
Print ReadLine(reader)
Wend
CloseFile(reader)
Return 1
End Function

Comments

Jesse2010
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 



Luke1112010
And what would the corresponding section be?


Jesse2010
Either BlitzMax Beginners Area or BlitzMax programming.


Luke1112010
Ok I will do that next time


Code Archives Forum