×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
for a project with an external supplier I have to do some encryption. I
received a java script as example.Have no knowledge of JS .
We are trying to write this in RPG , but because we have no knowledge on
crypto API's we get stuck.
the js looks like
//Prepare RSA public key and encrypt details
console.log(this.publicKey);
let publicKey = forge.util.decode64(this.publicKey);
console.log(publicKey);
let rsaPublicKey = forge.pki.publicKeyFromPem(publicKey);
console.log(JSON.parse(JSON.stringify(rsaPublicKey)));
let keyString = rsaPublicKey.toLocaleString();
console.log(keyString);
let encryptedDetails = rsaPublicKey.encrypt(details, 'RSA-OAEP', {
md: forge.md.sha256.create()
});
console.log(encryptedDetails);
let encodedDetails = forge.util.encode64(encryptedDetails);
console.log(encodedDetails);
The public key we receive looks like
:LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQ0lqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FnOEFNSUlDQ2dLQ0FnRUEzbm1YdUxRN0RGa2JlZC8rcGdBKwpqUGNPZ2pYaGxEaXVYRFVZNThBVGU0SDF3ZWxJalVBTTNyZkZsd3RVUVhXQ1NTeGtNb0NPK016V1pTblpOdFYxCm9BZnZ4a2t6MFErQkpUSENCTHpzMnpvUzlrMXM3cVZEbUJVdnV2VmVrZUZBUkkzV2lOeE52RTdWYTJWU1dqRjcKZ3hYTDBTVTFKUk8xTFJSb0N4WTI4dFFFcTg1bXVJUmpFQXNjLzRkL0hjY1NWUkRTaDFuQmNsMVVjZWxQVW9HZgpObjlCODBBZXJlMnBJYWRiQXVBSEZBZWc1WnUyb2haOGNXVHhKUUVJQlMwZFlyWWN6ZTZXdVBiRk9OYWpacXN6CnFqTWhLblV1bTV4Q1U2YXZRZUxJc0JoUlNkVEpBN09IVFJwemgvSlBuYzJUYXpxYlFVWVR0R1Iwb1BHRmQwaEIKSjZpMjAwdVgxSWcybURQZGRGd1EzZk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b9yJBb4jnB0oVnXKnRW3QwPuwT34ohsdDfEuvl1YS
SOBH3QXw1MjuN1W/nu6Am7ZhlWO3p+4YM07gTaer3pLYc+RgnvwWr//r1ztRjHpR
6RVXKFCEnRQd3IKCcMV3tcC1eSTn9hygI2m+hL/Zmjhx2/um81yXubgHDHRcBgyO
viuXxg29TVRHVo3AMd0++dECAwEAAQ==
-----END PUBLIC KEY-----
From what I understand from the js I need to encrypt my data with the
given key and a signing hash SHA256
I tried this with QC3CalculateSignature. Is this the API to use ?
Always get error
Message ID . . . . . . . . . : CPF9DDB
Message file . . . . . . . . : QCPFMSG
Library . . . . . . . . . : QSYS
Message . . . . : The key string or Diffie-Hellman parameter string is
not
valid.
Cause . . . . . : Either there is an error in the BER encoding or the BER
encoded string describes an object not valid for this operation.
Recovery . . . : Correct the string and try the request again.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact
[javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.