Inscribing SNES ROMs

How to Encrypt ROM Files with a Password and Inscribe Them on Bitcoin

Disclaimer: 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.

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.

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');

Inscribing Your ROM

You can use any inscription service to inscribe your ROM files onto Bitcoin. We recommend OrdinalsBot, a website by the team who helped create the Pizza Ninjas project.

Last updated