Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Foreign Languages > Italian Forum
Home Register FAQ Members List Search Today's Posts Mark Forums Read


Criptare e decriptare un file


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-25-2008, 11:45 PM
Junior Member
 
Join Date: Mar 2008
Posts: 35
Default Criptare e decriptare un file

Ciao a tutti,
sto iniziando a fare i miei primi esperimenti col software. Tra questi, ho provato a modificare il file d'esempio dell'help online sulla funzione crypto per far sì che:
- venga letto un file prova.txt (è un normale file di testo, composto da circa 15 righe)
- criptato
- scritto il file criptato prova2.txt
Ovviamente, senza successo...
Riporto il listato (non inorridite):

'Crypto is a Crypto object and Bit is a Bitwise object
Sub Globals
Dim string(0) As Byte, secret(0) As Byte
PassPhrase = "my key" 'This is not recommended in real applications!!!
End Sub

Sub App_Start
FileOpen (c1,"prova.txt",cRead ,, cASCII)
Test = FileRead (c1)
FileClose (c1)
Encrypt
Bit.New1
Crypto.New1
End Sub

Sub Encrypt
string() = Bit.StringToBytes(Test,0,StrLength(Test)) 'Convert the string to an array of bytes.
secret() = Crypto.Encrypt(PassPhrase, string()) 'Save the encrypted data.
Encrypted = secret()
FileOpen (c1,"prova2.txt",cWrite,,cASCII)
FileWrite (c1,Encrypted)
FileClose (c1)
End Sub



Se lo mando in esecuzione, ottengo un errore dove si riporta che la variabile Test non è mai stata usata (alla riga 14, corrisponde al secondo EndSub).
Se elimino la Subroutine Encrypt includendola nel corpo della prima, il file prova2.txt viene scritto ma è vuoto...
Se provo inoltre ad escludere la criptatura, riesce a scrivere sul file prova2.txt ma solo la prima riga...

Non riesco a trovare soluzione rileggendo le sintassi... qualcuno può aiutarmi a capire?
Di sicuro nel listato vi sono errori grossolani, non c'è dubbio. Grazie anticipatamente, e scusate l'incompetenza...

Last edited by Raytracer : 03-26-2008 at 12:14 AM.
Reply With Quote
  #2 (permalink)  
Old 03-26-2008, 01:01 AM
Junior Member
 
Join Date: Mar 2008
Posts: 35
Default

Cercando una risposta, mi sono imbattuto in questo topic:
Encrypt / Decrypt a complete file
relativo proprio al crypt-decrypt di un file.
Grazie a Erel, posso capire i miei errori!
Problema risolto!

Last edited by Raytracer : 03-26-2008 at 01:06 AM.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
CSV file generates strange start in file sunnyboyj Questions & Help Needed 9 12-21-2007 08:38 PM


All times are GMT. The time now is 05:49 PM.


Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0