Question please how to encrypt files asp

Snitz™ Forums 2000
https://forum.snitz.com/forumTopic/Posts/70457?pagenum=1
05 November 2025, 00:07

Topic


AHMEDHHH1
Question please how to encrypt files asp
15 March 2013, 17:14


Question please how to encrypt files asp
Files will give whatever for one Ac_khas and will use it on a local server http://localhost/
And I want to protect the files from the use on another computer

What are the ways of protection that you advise me

 

Replies ...


Carefree
15 March 2013, 21:10


Look at this example: Encoding Files Using ASP
AHMEDHHH1
17 March 2013, 14:15


Is there a database inside Windows computer far from means Balramat or Albroossor
So as Windows has been deleted LOSE this information can be found to the device
+ Was found in what is on track
Is if you were adding this path will be identified as any database or has a special connection method and knock the introduction of private data
AHMEDHHH1
17 March 2013, 14:51


How do I use the file encryption professor Carefree
For example, I want to encrypt a file (d. Asp)

Error Type:
Microsoft VBScript runtime (0x800A01F4)
Variable is undefined: 'WScript'
/fl/p.asp, line 8
Carefree
17 March 2013, 17:06


Originally posted by AHMEDHHH1
How do I use the file encryption professor Carefree
For example, I want to encrypt a file (d. Asp)

Error Type:
Microsoft VBScript runtime (0x800A01F4)
Variable is undefined: 'WScript'
/fl/p.asp, line 8

Post a link to your "p.asp" file in .txt format for us to look at.
AHMEDHHH1
03 April 2013, 15:46


Thank you Professor
Carefree
Carefree
04 April 2013, 04:15


Where is the link to the "p.asp" file? I can not detect the error without seeing the file.
AHMEDHHH1
08 April 2013, 16:10


The problem is that the language of Arabic this did not put the file because different language to Gatkm
I want to encrypt the file

http://pilot.somee.com/p.txt
Carefree
08 April 2013, 21:35


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
decrypt it again.
To encrypt, input the file name into the encrypt field.
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.
Code:

<!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>"
%>
AHMEDHHH1
09 April 2013, 09:47


Thanks Professor
Carefree
Will be tested soon
Carefree
10 June 2013, 12:08


In regard to the code I posted above, I've been trying to make it support unicode characters; however, I've been singularly unsuccessful. AscW (vs Asc) doesn't work, but I know that Asc is the issue. Anyone have an idea?
Carefree
13 August 2013, 14:26


Originally posted by Carefree
In regard to the code I posted above, I've been trying to make it support unicode characters; however, I've been singularly unsuccessful. AscW (vs Asc) doesn't work, but I know that Asc is the issue. Anyone have an idea?

Didn't want to edit such an old reply, but my brain finally kicked in on this topic. You should be able to use Arabic, Chinese, Korean, etc. if you change the 3rd line in the code above from this:
Code:
Response.Charset="UTF-8"
to this:
Code:
Response.Charset="UTF-16"
I don't read Arabic, though, and cannot be sure whether the results are what I want.
© 2000-2021 Snitz™ Communications