• 0
Sign in to follow this  
amauridebarros

(Resolvido) Converter Codigo em java para delphi

Question

Bom dia

 

Preciso converter um código que está em Java para usar no delphi. este código criptografa uma senha.
Alguém consegue converter este código para pascal pois eu conhecimento em java é bem próximo de zero:

******************************************************************************************

import java.util.Base64;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;

public class Cryptography
{
private static String key = "[email protected]#1$1%M4SC4D";
private static String iv = "C#&UjO){QwzFcsPs";

public static String encrypt(String plainText) throws Exception
{
byte[] plainTextbytes = plainText.getBytes("UTF-8");
byte[] keyBytes = key.getBytes("UTF-8");
byte[] ivBytes = iv.getBytes("UTF-8");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
SecretKeySpec secKey = new SecretKeySpec(keyBytes, "AES");
cipher.init(Cipher.ENCRYPT_MODE, secKey, new IvParameterSpec(ivBytes));
return Base64.getEncoder().encodeToString(cipher.doFinal(plainTextbytes));
}
}
obrigado;

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this