PAGUE 6 MESES
LEVE 12 MESES
GARANTIR DESCONTO

Fórum Converter código JAVA em CSharp #501973

21/11/2014

0

Pessoal, preciso converter o código fonte abaixo (JAVA) em C#. Alguém poderia me ajudar?

private Key gerarChave(String chave) {
byte[] chaveDecode = Base64.decodeBase64(chave.getBytes());
Key key = new SecretKeySpec(chaveDecode, "AES");
return key;
}

private String cifrar(String textoOriginal, String chave) throws Exception {
try {
byte[] original = textoOriginal.getBytes();
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.ENCRYPT_MODE, gerarChave(chave));
byte[] cifrada = cipher.doFinal(original);
byte[] retorno = Base64.encodeBase64(cifrada);
return new String(retorno);
} catch (Exception ex) {
throw new Exception(ex);
}
}
Carlo Ferreira

Carlo Ferreira

Responder

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar