Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7495617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:14:11+00:00 2026-05-29T18:14:11+00:00

am trying to protect bytes data using the protectedmemory and protecteddata in .net application

  • 0

am trying to protect bytes data using the protectedmemory and protecteddata in .net application

form this site, http://www.codedigest.com/Articles/Framework/69_Data_Encryption_and_Decryption_using_DPAPI_classes_in_NET.aspx
is seems i can only protect a few bytes

and also, i cannot get the sample provided here http://msdn.microsoft.com/en-us/library/ms229741(v=vs.85).aspx to run

I get the following errors:

Name ‘MemoryProtectionScope’ is not declared. (BC30451)
Name ‘DataProtectionScope’ is not declared. (BC30451)
Name ‘ProtectedMemory’ is not declared. (BC30451)

can anyone help me with other methods of doing this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T18:14:14+00:00Added an answer on May 29, 2026 at 6:14 pm

    What makes you think that you can only protect a few bytes from that article ? The API is quite simple – remember that the encryption doesn’t happen in place, a new array is returned with the encrypted content.

    Here is a full example of using ProtectedData.Protect and back:

    void Main()
    {
        string data  = new WebClient().DownloadString("http://www.stackoverflow.com");
        var buffer = Encoding.UTF8.GetBytes(data);
        buffer = System.Security.Cryptography.ProtectedData.Protect(buffer, null, System.Security.Cryptography.DataProtectionScope.CurrentUser);
        // Data is now protected.
    
        // Unprotect
        buffer = System.Security.Cryptography.ProtectedData.Unprotect(buffer, null, System.Security.Cryptography.DataProtectionScope.CurrentUser);  
        string decrypted = Encoding.UTF8.GetString(buffer);
        Debug.Assert(data == decrypted);
    }
    

    Also, you will need to add a reference to the System.Security assembly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use Dotfuscator (CE) to help protect our ASP.NET MVC .ddl.
Stasm (http://www.milbo.users.sonic.net/stasm/index.html) is a C++ library for finding features on image, applying the concept
I'm trying to password protect a directory on a server that's running IIS. I've
I am working on a VB.Net project and trying to get it to pull
I'm currently working on a ASP.Net 3.5 project and trying to implement session timeout
Trying to keep all the presentation stuff in the xhtml on this project and
I'm trying to save an XML file encoded as UTF-16 with cElementTree. This is
I'm trying to read Shoutcast stream and then play it using MediaStreamSource. Here is
I am trying to figure out on which data the crc32 field in the
I've been trying to figure this out for hours and it's soo frustrating! I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.