You would have to start by getting the values of the Arabic script into their Ascii equivalents. This program only supports the extended Ascii character set. After that, this should do it. This uses the "readfile" method (reads the entire contents into a variable in one piece), so there's a limit on how large it could be.
Put this into the folder with the text file to be encrypted. Make sure the folder has write permissions set for IUSR, IIS_IUSRS, & NETWORK SYSTEM.
This will read the text file and create two others. One will be the encrypted equivalent, the other will be the random keys necessary to
To decrypt, simply put the key file ("-c suffix") into the same folder with the encrypted file ("-e suffix") and input the "-e" file name into the decrypt field.
<!DOCTYPE HTML>
<%
Response.Charset="UTF-8"
dim strText, strPath, FilePath
Const FSOForReading = 1
Const FSOForWriting = 2
If Request("encr")>"" Then
strPath=Request("encr")
strName=left(strPath,len(strPath)-4)
FilePath=Server.Mappath(strPath)
FilePath1=Server.Mappath(strName&"-e")&right(strPath,4)
FilePath2=Server.Mappath(strName&"-c")&right(strPath,4)
On Error Resume Next
Error.Clear
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(FilePath1) Then
objFSO.DeleteFile(FilePath1)
End If
If objFSO.FileExists(FilePath2) Then
objFSO.DeleteFile(FilePath2)
End If
If objFSO.FileExists(FilePath) Then
Set objTextStream = objFSO.OpenTextFile(FilePath, FSOForReading)
Set objTextStream2 = objFSO.OpenTextFile(FilePath1,FSOForWriting,true)
Set objTextStream3 = objFSO.OpenTextFile(FilePath2,FSOForWriting,true)
End If
strText=objTextStream.ReadAll
For i = 1 to len(strText)
Randomize
j=int(Rnd*128)+1
If asc(mid(strText,i,1))>128 Then
objTextStream2.Write chr(asc(mid(strText,i,1))-j)
objTextStream3.Write -j&","
Else
objTextStream2.Write chr(asc(mid(strText,i,1))+j)
objTextStream3.Write j&","
End If
Next
objTextStream.Close
Set objTextStream = Nothing
objTextStream2.Close
Set objTextStream2 = Nothing
objTextStream3.Close
Set objTextStream3 = Nothing
Set objFSO = Nothing
Set objFSO = Nothing
Response.Write "<a href=""" & strName & "-e"&right(strPath,4)&""">Encrypted</a><br /><a href=""" & strName & "-c"&right(strPath,4)&""">Key File</a><br /><br />"
ElseIf Request("decr")>"" Then
strPath=Request("decr")
strName=left(strPath,len(strPath)-6)
FilePath=Server.Mappath(strPath)
FilePath1=Server.Mappath(strName&"-c")&right(strPath,4)
FilePath2=Server.Mappath(strName&"-d")&right(strPath,4)
On Error Resume Next
Error.Clear
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(FilePath2) Then
objFSO.DeleteFile(FilePath2)
End If
If not objFSO.FileExists(FilePath1) Then
Response.Write "Key file not found."
Response.Write "<meta http-equiv=""Refresh"" content=""2; URL=Encrypt.asp"">"
Response.End
End If
If objFSO.FileExists(FilePath) Then
Set objTextStream = objFSO.OpenTextFile(FilePath, FSOForReading)
Set objTextStream2= objFSO.OpenTextFile(FilePath1,FSOForReading)
Set objTextStream3= objFSO.OpenTextFile(FilePath2,FSOForWriting,true)
End If
strText=objTextStream.ReadAll
strText2=objTextStream2.ReadAll
j=0
For i = 1 to len(strText2)
If not mid(strText2,i,1)="," Then
strCode=strCode&mid(strText2,i,1)
Else
j=j+1
objTextStream3.Write chr(asc(mid(strText,j,1))-strCode)
strCode=""
End If
Next
objTextStream.Close
Set objTextStream = Nothing
objTextStream2.Close
Set objTextStream2 = Nothing
objTextStream3.Close
Set objTextStream3 = Nothing
Set objFSO = Nothing
Response.Write "<a href=""" & strName&"-d"&right(strPath,4)&""">Decrypted</a><br /><br />"
End If
Response.Write "<form action=""encrypt.asp"" method=""get"">" & _
" Encrypt: <input type=""text"" name=""encr"" /><br />" & _
" Decrypt: <input type=""text"" name=""decr"" /><br />" & _
" <input type=""submit"" value=""submit"" />" & _
"</form>"
%>