Initial commit
This commit is contained in:
16
public/models/encrypt.cjs
Normal file
16
public/models/encrypt.cjs
Normal file
@@ -0,0 +1,16 @@
|
||||
const crypto = require("crypto");
|
||||
const fs = require("fs");
|
||||
|
||||
const encryptFile = (inputFile, outputFile, password) => {
|
||||
const key = crypto.createHash("sha256").update(password).digest();
|
||||
const iv = crypto.randomBytes(16);
|
||||
|
||||
const cipher = crypto.createCipheriv("aes-256-cbc", key, iv);
|
||||
const input = fs.createReadStream(inputFile);
|
||||
const output = fs.createWriteStream(outputFile);
|
||||
|
||||
output.write(iv);
|
||||
input.pipe(cipher).pipe(output);
|
||||
};
|
||||
|
||||
encryptFile("character.glb", "character.enc", "Character3D#@");
|
||||
Reference in New Issue
Block a user