Encrypting, decrypting - any better idea how to work with file?

Discussion in 'Chit Chat' started by Standa, Apr 2, 2008.

  1. Standa

    Standa Member Licensed User

    Hi, maybe stupid question, but...
    I am trying to write passwords storage software using crypto library. What is better:
    1) Encrypt whole text file with passwords, and when need to read, decrypt this file, save it to string and read.
    ...or...
    2) Encrypt only separate items like www site, nick, pass etc., and save it to readable file. On reading, decrypt only those items what I need to see.
    ...or...
    3) everything is bad, I have better solution for you... :)

    Here is planned format for storage file:

    I hope, you understand me, this post is very close to the end of my English knowledge :)
     
  2. LineCutter

    LineCutter Active Member Licensed User

    I'd use a table & "save" it as a CSV (process it as an array before saving). Then you can load the encrypted file, covert back to csv & use that to feed a table in memory. Makes referencing the data much easier later, as well as obfuscating the structure of your file.

    Then again if you're paranoid about someone sneaking a peak at your memory then you are probably using the wrong solution all together.
     
  3. Standa

    Standa Member Licensed User

    Yes, table looks like best idea, it saves a lot of my work. Thanks :)
     
  4. Gapple

    Gapple Member Licensed User

    Tables, CSV and Encryption - New guy needs help

    Hi all, just bought Basic4ppc and thanks to this forum have got up and running more or less in just a few days. I would like to encrypt then write to table and save as CSV. It's the retrieving that gets me :( I have read and re-read the postings regarding Crypto and I have spent hours trying to get it to work to no avail. I have managed to encrypt using Crypto, writing to a table cell, and then saving to CSV. When retrieving the encrypted information from loading, the data looks good. However, I am unable to 'paste' that secret() back into the Sub btnDecrypt_Click and have it return the original value. I would be most grateful if someone would give some example code if they have succeeded in using CSV with the Crypto.

    New to Basic4ppc (Franco-american in Italy),

    Georges Louis
    ________
    Zoloft Side Effect
     
    Last edited: Sep 18, 2011
  5. agraham

    agraham Expert Licensed User

    Might be easier if you posted your code so we can see where you are going wrong. The Crypto library is limited by having to run under .NET 1.1/1.0. If you are running .NET 2.0 then my CryptoEx library is somewhat more comprehensive (actually that's a bit of an understatement :)) and includes examples http://www.basic4ppc.com/forum/additional-libraries/2220-cryptoex-library.html

    @Erel - might be better shifting this thread to Questions ...
     
  6. Gapple

    Gapple Member Licensed User

    Thank you !

    Thanks so much for the quick reply and yes I'm running under .NET 2.0 I'll review your CryptoEx library. If my efforts remain unsuccessful, I'll be sure to attach code next time.

    It's a real pleasure to see such prompt and generous forum members.

    Grazie,

    Georges Louis
    ________
    Peach
     
    Last edited: Sep 18, 2011
  7. Gapple

    Gapple Member Licensed User

    Word of thanks to Agraham

    Got the Basic64 functions to work right away ! I am encrypting the data, writing to table cells then saving the table to CSV. When retrieving the data after Loading the CSV, the data "decrypts" perfectly. Thank you again !

    Georges Louis
    ________
    Squirtlady cam
     
    Last edited: Sep 18, 2011
  8. agraham

    agraham Expert Licensed User

    You realize, I hope, that Base64 is a standard coding scheme not an encryption and as such has no security whatsoever!
     
  9. Gapple

    Gapple Member Licensed User

    Base64

    Right - Just some positive feedback on your library. I thought of using a secret-key algorithm for the application. Your help file mentions a choice of several. Could you recommend one to get started with ?
    ________
    Paxil sickness
     
    Last edited: Sep 18, 2011
  10. agraham

    agraham Expert Licensed User

    Thank you. Much appreciated :)
    Rijndael is the latest and strongest. However its minimum block size is 128 bits so if you encrypt lots of separate small items of data the storage overhead is twice that of the other algorithms. Unless you are paranoid about your data a 128 bit key is sufficient. The next strongest is TripleDES but for domestic use plain DES is probably as good and cheaper computationally unless you are paranoid that GCHQ or the NSA are watching you. RC2 is of historic interest only.
     
  11. Gapple

    Gapple Member Licensed User

    UTF-8 supported in encryptions ?

    Thanks again for your suggestions. Before going too far, I experimented with the demo code of Rijndeal and DES. I substituted the line 41. test="01234567890abcdefg" with a string using French accents "H?l?ne est tr?s belle" only to find the MSG did not return the accented characters. Further, I wrote the same string (str) to the TextBox1 of the form1 with the same result.

    Sorry, I'm new to this. Could you explain how to work around this apparent UTF-8 incompatibility ?

    Thanks for your patience.
    ________
    Anal Webcams
     
    Last edited: Sep 18, 2011
  12. agraham

    agraham Expert Licensed User

    Use DecryptString which is commented out in the demos. I've just noticed that there is a typo in the DecryptString line, it omits the buffer parameter. It should read
    Code:
    str = Des.DecryptString(code())
    EDIT:- Note that the problem is one of display, not a decryption problem. Encrypt string knows about UTF8 and so does DecryptString. Just displaying the decoded UTF8 bytes as characters looks wrong but is in fact correct and also shows the string padding referred to in the comments.
     
    Last edited: Sep 1, 2008
Loading...