You can then shuffle it back to it's original working state.
I have automated a key here, but it can be passed or remembered separately.
The fb subs are the mixing engine, which of course I have now given away.
I have added a "t" then a "tt" to the filename for the demo, but you don't need to do this.
Code: Select all
#include "crt.bi"
#include "file.bi"
Sub save(content As String,filename As String)
Var fp=fopen(filename,"wb")
If fp = 0 Then Print "Unable to save ";filename:sleep:end
fwrite(@content[0], 1, Len(content), fp)
fclose(fp)
End Sub
Sub load(content As String,filename As String)
content=String(Filelen(filename),0)
Var fp=fopen(filename,"rb")
If fp = 0 Then Print "Unable to open ";filename:sleep:end
fread(@content[0], 1, Len(content), fp)
fclose(fp)
End Sub
Sub shuffle(a As String)
#define range(f,l) Int(Rnd*(((l)+1)-(f))+(f))
Dim As Long L1=Len(a)-1
For n As Long = 0 To Len(a)-2
Swap a[n], a[range((n+1),L1)]
Next n
End Sub
Sub shuffleback(a As String)
#define range(f,l) Int(Rnd*(((l)+1)-(f))+(f))
Dim As Long L=Len(a)-2,L1=Len(a)-1
Redim As Long ar(L)
For n As Long = 0 To Len(a)-2
ar(L-n)=(range((n+1),L1))
Next n
For n As Long=0 To Len(a)-2
Swap a[L-n],a[ar(n)]
Next n
End Sub
Sub saveshuffle(content As String,filename as string)
Var x=Int(Rnd*1000000)
Randomize x
shuffle(content)
save(Str(x)+":"+content,filename)
End Sub
Function getshuffleback(filename As String) As String
Dim As String L
load(L,filename)
Var v=Vallng(L)
L=Mid(L,Instr(L,":")+1)
Randomize v
shuffleback(L)
Return L
End Function
'===========================================
dim as string filename="typeshapesanddodeca.exe" '<--- your file
randomize
dim as string content
load(content,filename)
saveshuffle(content,"t"+filename) '"t"+filename is gobbledygook
save(getshuffleback("t"+filename),"tt"+filename) '"tt"+filename is OK
print "done"
sleep