mirror of
https://github.com/gnh1201/welsonjs.git
synced 2024-11-26 15:31:42 +00:00
HIGHT(ISO/IEC 18033-3) encryption and decryption
This commit is contained in:
parent
453e63da2e
commit
4db4d98f0b
|
@ -239,7 +239,7 @@ namespace WelsonJS
|
|||
byte[] dataIn = Convert.FromBase64String(encryptedData);
|
||||
|
||||
HIGHT.ECB cipher = new HIGHT.ECB(userKey);
|
||||
return Encoding.UTF8.GetString(cipher.Decrypt(dataIn));
|
||||
return Encoding.UTF8.GetString(cipher.Decrypt(dataIn)).Trim('\0');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
12
app.js
12
app.js
|
@ -307,20 +307,18 @@ function require(pathname) {
|
|||
break;
|
||||
|
||||
case ".enc": // HIGHT(ISO/IEC 18033-3) encrypted
|
||||
T = (function(encryptedData) {
|
||||
T = (function(encryptedData, ToolkitInterface) {
|
||||
try {
|
||||
var toolkit = CreateObject("WelsonJS.Toolkit");
|
||||
var userKey = '';
|
||||
while (userKey.length == 0 || userKey.length > 16) {
|
||||
userKey = toolkit.Prompt("Enter the password:");
|
||||
userKey = ToolkitInterface.Prompt("This file has been encrypted. Please enter the password:");
|
||||
}
|
||||
return toolkit.DecryptStringHIGHT(encryptedData);
|
||||
return ToolkitInterface.DecryptStringHIGHT(userKey, encryptedData);
|
||||
} catch (e) {
|
||||
console.error("Failed to load the encrypted data:", e.message);
|
||||
return '';
|
||||
}
|
||||
})(T);
|
||||
|
||||
})(T, CreateObject("WelsonJS.Toolkit"));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -332,6 +330,8 @@ function require(pathname) {
|
|||
+ FN
|
||||
;
|
||||
|
||||
if (suffix == ".enc") console.log(T);
|
||||
|
||||
// execute
|
||||
try {
|
||||
cache[FN] = eval(T);
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
30
encryptor.js
Normal file
30
encryptor.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
// encryptor.js
|
||||
// HIGHT(ISO/IEC 18033-3) encryption and decryption tool for WelsonJS
|
||||
// Namhyeon Go <abuse@catswords.net>
|
||||
// https://github.com/gnh1201/welsonjs
|
||||
|
||||
var FILE = require("lib/file");
|
||||
var Toolkit = require("lib/toolkit");
|
||||
|
||||
function main(args) {
|
||||
if (args.length < 1) {
|
||||
console.error("Usage: cscript app.js encryptor <filename>");
|
||||
return 0;
|
||||
}
|
||||
|
||||
var filename = args[0];
|
||||
var userKey = '';
|
||||
while (userKey.length == 0 || userKey.length > 16) {
|
||||
userKey = Toolkit.prompt("Please enter the password for encryption:");
|
||||
}
|
||||
var data = FILE.readFile(filename, "utf-8");
|
||||
var encryptedData = Toolkit.encryptStringHIGHT(userKey, data);
|
||||
|
||||
var dstfile = filename + ".enc";
|
||||
FILE.writeFile(dstfile, encryptedData, "utf-8");
|
||||
console.log("Saved to", dstfile);
|
||||
|
||||
console.log("Done");
|
||||
}
|
||||
|
||||
exports.main = main;
|
|
@ -92,6 +92,14 @@ function closeProcess(pid) {
|
|||
return getInterface().CloseProcess(pid);
|
||||
}
|
||||
|
||||
function encryptStringHIGHT(userKey, data) {
|
||||
return getInterface().EncryptStringHIGHT(userKey, data);
|
||||
}
|
||||
|
||||
function decryptStringHIGHT(userKey, encryptedData) {
|
||||
return getInterface().DecryptStringHIGHT(userKey, encryptedData);
|
||||
}
|
||||
|
||||
exports.create = create;
|
||||
exports.getInterface = getInterface;
|
||||
exports.sendClick = sendClick;
|
||||
|
@ -103,8 +111,10 @@ exports.prompt = prompt;
|
|||
exports.NamedSharedMemory = NamedSharedMemory;
|
||||
exports.openProcess = openProcess;
|
||||
exports.closeProcess = closeProcess;
|
||||
exports.encryptStringHIGHT = encryptStringHIGHT;
|
||||
exports.decryptStringHIGHT = decryptStringHIGHT;
|
||||
|
||||
exports.VERSIONINFO = "WelsonJS.Toolkit Native API version 0.3.4";
|
||||
exports.VERSIONINFO = "WelsonJS native component (WelsonJS.Toolkit) version 0.3.5";
|
||||
exports.AUTHOR = "abuse@catswords.net";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
|
Loading…
Reference in New Issue
Block a user