Not quite sure if this would be the best place to post this, but if not I'm sorry.

Was just wondering, I heard there was a way to save a file, and require a password to reopen it? Is this true? And if so how do I do that? And is this true for a graphics file as well?

I'm using windows XP if that makes a difference :)

Thanks for any help,
MoNkEe

Dani AI

Generated

Short summary for : there are two different ways to make a file “ask for a password” — control access at the OS level (permissions) or encrypt the file so a password (or derived key) is required to decrypt it. ’s suggestion about permissions is useful if you want to stop other OS users from seeing a file, but it does not implement a password-check inside your game. For a game that reveals a graphic when a player types the right code, encrypting the image and decrypting it at runtime is the right approach.

Practical options to consider (with tradeoffs):

  • Use a strong encrypted archive or container that supports modern AES (recommended when you want a quick, external tool).
  • Ship assets encrypted and decrypt them inside the game when the correct password is entered (better control and cross-platform behavior).
  • Use format-specific protection only for formats that support it natively (some document formats do; plain images do not).

Example workflow for an in-game unlock (use a trusted crypto library; do not roll your own):

salt = read_header_salt(encrypted_file)
key = PBKDF2(password, salt, iterations=200000, dklen=32)
nonce, ciphertext, tag = read_encrypted_blob(encrypted_file)
plaintext = AES_GCM_Decrypt(key, nonce, ciphertext, tag)
image = load_image_from_memory(plaintext)
display(image)

Security notes and troubleshooting: always use a standard library that supports authenticated encryption (AES-GCM or similar) and a key-derivation function like PBKDF2 with a generous iteration count. Store a random salt and nonce with the file; do not write decrypted bytes back to disk unless strictly necessary. Test with different passwords and check for library-specific pitfalls (endianness, padding modes, incorrect tag handling). For details on key derivation see RFC 2898 (PBKDF2). For user-friendly encrypted archives or containers, reputable tools are available that support AES-256.

Recommended Answers

All 3 Replies

Put the file in a folder ,right click on the folder and choose ,sharing and security and follow the directions ,if the check box is greyed out ,check out learn more about sharing and security at the bottom of the window that opens .

Thanks for the reply, but I was thinking more along the lines, if I want to put a code in a textbased game I am working on, where if you find the password, you can open a file with graphics (in a seperate window) that coincides with it... ?

I'm not sure if I am explaining this right?

LOL, I finally stopped thinking about it for a second, and the obvious answer of WinZip came to me... thanks tho to all who have taken the time to read this, and as well thanks for the reply caperjack :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.