# Inscribing SNES ROMs

<mark style="color:red;">**Disclaimer:**</mark> <mark style="color:red;"></mark><mark style="color:red;">Inscribing ROMs under copyright, even if you own the original copy, encrypt it with a password, and use it only for personal use still exists in a legal gray area. This tutorial is for informational purposes only. Readers are responsible for complying with copyright laws and are advised to seek legal counsel if necessary. The creator of this tutorial bears no liability for any legal consequences arising from its use.</mark>

### **Encrypting ROM Files with a Password**

Save the following code into a JavaScript file (for example, encrypt\_rom.js) and place it in the same directory as the ROM file you want to encrypt. Modify line 32 to include the name of your ROM file and your selected password. Open the terminal or your preferred command line tool and navigate to that directory. Then, execute the JavaScript file using Node.js by typing `node encrypt_rom.js` and pressing enter. This action will generate an encrypted version of the ROM file using the password you chose.

{% code lineNumbers="true" %}

```javascript
const crypto = require('crypto');
const fs = require("fs");

function encrypt(key, plaintext) {
  const nonce = getRandomIV();
  const cipher = crypto.createCipheriv('aes-256-gcm', key, nonce);
  const nonceCiphertextTag = Buffer.concat([
    nonce,
    cipher.update(plaintext),
    cipher.final(),
    cipher.getAuthTag()
  ]);
  return nonceCiphertextTag;
}

function getRandomIV() { return crypto.randomBytes(12); }

function encryptRom(name, password) {
  fs.readFile(name, function (err, data) {
    if (err) throw err;
    const hex = crypto.createHash('sha256').update(password).digest('hex').slice(0, 32);
    const key = Buffer.from(hex);
    const cipher = encrypt(key, data);
    try {
      fs.writeFileSync(`./encrypted-${name}`, cipher);
    } catch (err) {
      console.error(err);
    }
  });
}

encryptRom('ROM.sfc', 'mypassword');
```

{% endcode %}

### Inscribing Your ROM

You can use any inscription service to inscribe your ROM files onto Bitcoin. We recommend [OrdinalsBot](https://ordinalsbot.com), a website by the team who helped create the Pizza Ninjas project.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ninjalerts.gitbook.io/bitcoin-ordinals-pizza-ninjas/inscribing-snes-roms.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
