forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Windows XP File Encryption

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced VDS 5 Source Code
View previous topic :: View next topic  
Author Message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Fri Aug 22, 2003 3:59 pm    Post subject: Windows XP File Encryption Reply with quote

With this demo you can see how to use the Windows API to encrypt
a file using Windows XP's built-in encryption. This encryption is not
visible to the user who created it but uses not logged on as the
person who encrypted the file. This is nice for a personal security
app or something. Hopefully someone finds it useful.

BTW, to tell if the file is encrypted, its name and details in Explorer
will appear in green text unless the user has changed it.

Enjoy. Smile

Code:
#################################
# Windows XP File Encryption    #
# By FreezingFire               #
#                               #
# I disclaim all liability      #
# relating to the use of this   #
# script. USE AT YOUR OWN RISK  #
#                               #
# Requires Windows XP and VDS 5 #
#################################


# Check to see if using Windows XP
if @unequal(@sysinfo(winver),5.1)
warn You don't appear to be running Windows XP.@cr()This example requires Windows XP.
end

# Change this to the sample file you'd like to CREATE and ENCRYPT
%%file = C:\VDS5_Encrypt_Test.txt

#### START CREATION OF SAMPLE TEXT FILE ####
%%file_dest = %%file
if @file(%%file_dest)
  if @ask(The file you chose will be overwritten! Are you sure you want to continue?)
    file delete,%%file_dest
  else
    exit
  end
end
list create,1
list loadtext,1
"This is a test text file to be encrypted with Windows XP's cryptography API functions
"http://forum.vdsworld.com/
"This file may be removed if not wanted
list savefile,1,%%file_dest
list close,1
#### END CREATION OF SAMPLE FILE ####
title By FreezingFire
shell open,@path(%%file_dest)
warn Sample file created.@cr()Press OK to encrypt file

# Encrypt File
loadlib advapi32.dll
%A = @lib(advapi32,EncryptFileA,BOOL:,STR:%%file_dest)
freelib advapi32.dll
info Encrypt Return Code:@cr()%A

# Wait for user to continue example
warn Press OK to decrypt file

# Encrypt File
loadlib advapi32.dll
%A = @lib(advapi32,DecryptFileA,BOOL:,STR:%%file_dest)
freelib advapi32.dll
info Decrypt Return Code:@cr()%A

if @ask(End of demonstration. Delete sample file?)
  file delete,%%file_dest
  info Sample file deleted
end
exit

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Fri Aug 22, 2003 7:05 pm    Post subject: Reply with quote

BTW,
This should work in Win2k Pro as well Wink Good job... Also I might add it is not nessessary to Free the library after every function call...Just load the DLL once and then free it when the program is finished...but for this simple example I guess this is good enough Wink

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Fri Aug 22, 2003 11:49 pm    Post subject: Reply with quote

Yup, I tried to keep the sections of encrypt and decrypt as easy as
possible to just copy and paste. Thanks for the compliment. Very Happy

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Sat Aug 23, 2003 5:13 am    Post subject: Reply with quote

FF nice example Smile
I have added file highlighting to the Shell command. This will open the
folder and highlight the file. (You can get a few more explorer commands in a package I put on the forum I think).
Lot more cyptography stuff could be accessed but for the 8 parameter limitation of VDS @LIB() function.
Code:
#################################
# Windows XP File Encryption    #
# By FreezingFire               #
#                               #
# I disclaim all liability      #
# relating to the use of this   #
# script. USE AT YOUR OWN RISK  #
#                               #
# Requires Windows XP and VDS 5 #
#################################


# Check to see if using Windows XP
if @unequal(@sysinfo(winver),5.1)
warn You don't appear to be running Windows XP.@cr()This example requires Windows XP.
end

# Change this to the sample file you'd like to CREATE and ENCRYPT
%%file = C:\VDS5_Encrypt_Test.txt

#### START CREATION OF SAMPLE TEXT FILE ####
%%file_dest = %%file
if @file(%%file_dest)
  if @ask(The file you chose will be overwritten! Are you sure you want to continue?)
    file delete,%%file_dest
  else
    exit
  end
end
list create,1
list loadtext,1
"This is a test text file to be encrypted with Windows XP's cryptography API functions
"http://forum.vdsworld.com/
"This file may be removed if not wanted
list savefile,1,%%file_dest
list close,1
#### END CREATION OF SAMPLE FILE ####
title By FreezingFire
#shell open,@path(%%file_dest)
SHELL open,Explorer,/n","/select","%%file_dest"
WAIT 3
warn Sample file created and @CR()highlighted for your convenience.@cr()Press OK to encrypt file

# Encrypt File
loadlib advapi32.dll
%A = @lib(advapi32,EncryptFileA,BOOL:,STR:%%file_dest)
freelib advapi32.dll
info Encrypt Return Code:@cr()%A

# Wait for user to continue example
warn Press OK to decrypt file

# Encrypt File
loadlib advapi32.dll
%A = @lib(advapi32,DecryptFileA,BOOL:,STR:%%file_dest)
freelib advapi32.dll
info Decrypt Return Code:@cr()%A

if @ask(End of demonstration. Delete sample file?)
  file delete,%%file_dest
  info Sample file deleted @CR()You can now close the C:\ Folder
end
exit

Regards

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sun Aug 24, 2003 11:41 pm    Post subject: Reply with quote

Nice one CodeScript. I didn't know about that file selection parameter
and I've been wondering how to do that. Very Happy

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced VDS 5 Source Code All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group