Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

Need help understanding Crypto

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-15-2008, 12:38 PM
Basic4ppc Veteran
 
Join Date: Apr 2008
Location: Gosford NSW Australia
Posts: 223
Send a message via MSN to tsteward
Default Need help understanding Crypto

I need help understanding how to use crypto.
Below is the code from the help file.
I have modified the sub so as to attempt to decrypt a string that had been previously encrypted.
Obviously I am doing it wrong.
Please run the code and click decrypt without doing anything else. I am trying to supply and encrypted string and decode it.

Code:
Sub Globals
      
Dim string(0As Byte, secret(0As Byte 
                        
Dim NewArray(0)
      PassPhrase = 
"my key" 'This is not recommended in real applications!!!   
End Sub


Sub App_Start
      Form1.Show
      
Bit.New1
      Crypto.New1
End Sub


Sub btnEncrypt_Click
      
string() = Bit.StringToBytes(txtString.Text,0,StrLength(txtString.Text)) 'Convert the string to an array of bytes.
      secret() = Crypto.Encrypt(PassPhrase, string()) 'Save the encrypted data.
      For i = 0 To ArrayLen(secret())-1 'Show the encrypted data in the TextBox
            s = s & bit.DecToHex(secret(i))
      
Next
      txtString.Text = s
End Sub


Sub btnDecrypt_Click
      
'4ba21d28c8bf314927966675a8f1a46c this is "Hello World" encrypted
      secret()=Bit.StringToBytes("4ba21d28c8bf314927966675a8f1a46c",0,StrLength("4ba21d28c8bf314927966675a8f1a46c"))
      
string() = Crypto.Decrypt(PassPhrase,secret()) 'Decrypt the data.
      txtString.Text = Bit.BytesToString(string(),0,ArrayLen(string())) 'Convert the array to a string.
End Sub
__________________
PC: Dual core 3.4ghz 2gb ram
PPC: I-mate Jasjam
Reply With Quote
  #2 (permalink)  
Old 09-15-2008, 01:23 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

bit.StringToBytes doesn't do what you seem to think it does. You need a hex conversion. Check out here http://www.basic4ppc.com/forum/quest...pto-error.html and here
http://www.basic4ppc.com/forum/quest...ng-phrase.html and my BytesConverter library here http://www.basic4ppc.com/forum/addit...r-library.html
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 Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Crypto error Raytracer Questions (Windows Mobile) 4 07-31-2008 11:39 AM
Crypto Error Raytracer Italian Forum 0 07-30-2008 03:39 PM
Crypto - Which algorithm is used? Nycran Questions (Windows Mobile) 12 12-09-2007 07:45 PM
Crypto library was updated - 1.10 Erel Announcements 2 10-19-2007 07:44 AM


All times are GMT. The time now is 02:22 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0