Skip to content

Instantly share code, notes, and snippets.

/Main.java Secret

Created March 18, 2017 19:02
Show Gist options
  • Save anonymous/11f1b20510f4205bec655230ce9c5608 to your computer and use it in GitHub Desktop.
Save anonymous/11f1b20510f4205bec655230ce9c5608 to your computer and use it in GitHub Desktop.
*_���/�E��6�в�sqV?�<��k�Z]
x
p�+*�ri{E(-�r�>�-ʲeЖ��s-
Aq�s����.n�~�
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.*;
import java.nio.file.Files;
import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
public class Main {
public static void main(String[] args) throws IOException, InvalidAlgorithmParameterException, InvalidKeyException, NoSuchPaddingException, NoSuchAlgorithmException, BadPaddingException, IllegalBlockSizeException {
File AesKeyFile = new File("./Cipher2PHP/aes.key");
File InitializationVectorFile = new File("./Cipher2PHP/initialization.vector");
File EncryptedDataFile = new File("./Cipher2PHP/encrypted.data");
byte[] AesKeyData = Files.readAllBytes(AesKeyFile.toPath());
byte[] InitializationVectorData = Files.readAllBytes(InitializationVectorFile.toPath());
byte[] EncryptedData = Files.readAllBytes(EncryptedDataFile.toPath());
Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
SecretKeySpec keySpec = new SecretKeySpec(AesKeyData, "AES");
cipher.init(Cipher.DECRYPT_MODE, keySpec, new IvParameterSpec(InitializationVectorData));
byte[] result = cipher.doFinal(EncryptedData);
String decrypted = new String(result);
System.out.printf("Your data: %s\n", decrypted);
}
}
<?php
$AesKeyData = file_get_contents('./Cipher2PHP/aes.key');
$InitializationVectorData = file_get_contents('./Cipher2PHP/initialization.vector');
$EncryptedData = file_get_contents('./Cipher2PHP/encrypted.data');
$decrypted = openssl_decrypt(
$EncryptedData,
'AES-128-CBC',
$AesKeyData,
OPENSSL_NO_PADDING,
$InitializationVectorData
);
printf("Your data: %s\n", $decrypted);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment