Converter código JAVA em CSharp
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
Curtidas 0