locked
anyway around to detect an encrypted string? RRS feed

  • Question

  • hi,

    can i check whether this is an encrypted string or normal string?

    I am getting an exception when a string is already decrypted and my method is trying to decrypt it.


    Sunday, June 16, 2013 3:31 AM

Answers

  • Not accurate place to ask .

    try some language forums.

    Add something in addition to encrypted text and in that way , you 'll be able to find.

    something like that

    public Boolean  IsEncrypted(string cipherString)
    {
        if (string.IsNullOrEmpty(cipherString))
           return false;
    
        return cipherString.StartsWith("@");
    }



    Vote As Helpful, Propose As Answer, or Mark As Answer
    Microsoft Certified Solutions Developer
    My Samples


    • Edited by Mehmood Ahmed Sunday, June 16, 2013 5:30 AM
    • Marked as answer by neha-verma Sunday, June 16, 2013 6:31 PM
    Sunday, June 16, 2013 4:55 AM
  • Other way, inside your datamodel, you can have a flag (IsDecrypted) which you can set as soon data has been decrypted successfully. Next time before attempting decryption you can check the flag and if it is already decrypted, just return the already decrypted value.

    Or use separate properties to hold both original and decrypted value. If decrypted value is empty, then attempt decryption else return existing value.


    Thanks,
    Sachin
    My Samples


    • Edited by Sachin S Sunday, June 16, 2013 6:14 PM
    • Marked as answer by neha-verma Sunday, June 16, 2013 6:32 PM
    Sunday, June 16, 2013 6:12 PM

All replies

  • Not accurate place to ask .

    try some language forums.

    Add something in addition to encrypted text and in that way , you 'll be able to find.

    something like that

    public Boolean  IsEncrypted(string cipherString)
    {
        if (string.IsNullOrEmpty(cipherString))
           return false;
    
        return cipherString.StartsWith("@");
    }



    Vote As Helpful, Propose As Answer, or Mark As Answer
    Microsoft Certified Solutions Developer
    My Samples


    • Edited by Mehmood Ahmed Sunday, June 16, 2013 5:30 AM
    • Marked as answer by neha-verma Sunday, June 16, 2013 6:31 PM
    Sunday, June 16, 2013 4:55 AM
  • Other way, inside your datamodel, you can have a flag (IsDecrypted) which you can set as soon data has been decrypted successfully. Next time before attempting decryption you can check the flag and if it is already decrypted, just return the already decrypted value.

    Or use separate properties to hold both original and decrypted value. If decrypted value is empty, then attempt decryption else return existing value.


    Thanks,
    Sachin
    My Samples


    • Edited by Sachin S Sunday, June 16, 2013 6:14 PM
    • Marked as answer by neha-verma Sunday, June 16, 2013 6:32 PM
    Sunday, June 16, 2013 6:12 PM
  • Thanks Sachin and Mehmood.
    Sunday, June 16, 2013 6:32 PM
  • Sachin can you help me at here.

    I am getting a small exception while accessing the db file.

    Sunday, June 16, 2013 8:20 PM