PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Java en Windev
Java en Windev
Débuté par Z000007, 24 mai 2022 13:03 - 1 réponse
Membre enregistré
28 messages
Posté le 24 mai 2022 - 13:03
Hello,

Quelqu'un pourrait svp me traduire ce code java en windev ??
D'avance merci

import java.nio.charset.StandardCharsets;
import java.security.GeneralSecurityException;
import java.util.Base64;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
// Merchant secret key.
private static final String MERCHANT_SIGNING_KEY = "j5rbimXBU4BFGwCsHzounKRimhg=";
private static final String HMAC_SHA1_ALGORITHM = "HmacSHA1";
public static String sign(final String document) throws GeneralSecurityException {
// Get the key byte array.
byte[] merchantKeyBytes = Base64.getDecoder().decode(MERCHANT_SIGNING_KEY);
// Get the document byte array.
byte[] documentBytes = document.getBytes(StandardCharsets.UTF_8);
// Get the HMAC SHA1 algorithm.
Mac mac = Mac.getInstance(HMAC_SHA1_ALGORITHM);
// Initialize it with the merchant secret key.
mac.init(new SecretKeySpec(merchantKeyBytes, HMAC_SHA1_ALGORITHM));
// Generate the signature.
byte[] signatureBytes = mac.doFinal(documentBytes);
// Base64 encode the signature.
return Base64.getEncoder().encodeToString(signatureBytes);
}
220
Membre enregistré
3 311 messages
Popularité : +93 (137 votes)
Posté le 26 mai 2022 - 07:50
Pas besoin
Il existe déjà des fonctions de cryptage dans windev