Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Malformed URI when encrypting string using md5 #1053

Open
titan1230 opened this issue Oct 17, 2023 · 1 comment
Open

Malformed URI when encrypting string using md5 #1053

titan1230 opened this issue Oct 17, 2023 · 1 comment

Comments

@titan1230
Copy link

Kindly, help me solve this error of Malformed URI when encrypting string using md5.

The error is:

URIError: URI malformed
    at decodeURIComponent (<anonymous>)
    at Object.util.decodeUtf8 (/home/pi/Projects/scratcher/node_modules/node-forge/lib/util.js:1671:10)
    at ByteStringBuffer.util.ByteStringBuffer.toString (/home/pi/Projects/scratcher/node_modules/node-forge/lib/util.js:716:15)
    at /home/pi/Projects/scratcher/src/routes/offerwall/index.ts:32:99
    at Generator.next (<anonymous>)
    at /home/pi/Projects/scratcher/src/routes/offerwall/index.ts:8:71
    at new Promise (<anonymous>)
    at __awaiter (/home/pi/Projects/scratcher/src/routes/offerwall/index.ts:4:12)
    at /home/pi/Projects/scratcher/src/routes/offerwall/index.ts:12:36
    at Layer.handle [as handle_request] (/home/pi/Projects/scratcher/node_modules/express/lib/router/layer.js:95:5)

The code is:

import { md5 } from "node-forge";

const sub_id = encodeURIComponent(req.query.sub_id!.toString());
const amount = encodeURIComponent(req.query.amount!.toString());
const signature = req.query.signature!.toString();

const secret_key = encodeURIComponent(process.env.SECRET_KEY!);

if (!amount || !sub_id || !signature) {
        res.send("0");
        return;
}
    
let conn;
const md = md5.create()
const validation_signature = md.update(sub_id + ":" + amount + ":" + secret_key).digest().toString();

Your help would be greatly appreciated.

@titan1230
Copy link
Author

@siebertm @shellac @cadorn @andersk , Kindly help if you know the solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant