aes

Loading Encrypted JarFile Via URLCassloader

风格不统一 提交于 2019-12-03 22:28:22
I've been writing a little system to dynamically load AES encrypted jar files. My code: public static void main(String args[]) throws Exception { String jar = "http://site.com/api/rsc/test.jar"; List<URL> urls = new ArrayList<URL>(); urls.add(getURL(jar)); URL jarurl = urls.get(0); ObjectInputStream ois = new ObjectInputStream((new URL("http://site.com/api/rsc/key_1.txt").openStream())); Object o = ois.readObject(); DESKeySpec ks = new DESKeySpec((byte[])o); SecretKeyFactory skf = SecretKeyFactory.getInstance("DES"); SecretKey key = skf.generateSecret(ks); Cipher c = Cipher.getInstance("DES

Aes javascript encrypt - java decrypt

主宰稳场 提交于 2019-12-03 22:21:26
I'm trying to encrypt a message in javascript (using crypto-js library) and to decrypt it in java. This is the javascript code: var key = CryptoJS.enc.Utf8.parse(aesPassword); var ive = CryptoJS.enc.Utf8.parse(aesIv); var encryptedData = CryptoJS.AES.encrypt(dataToEncrypt, key, {mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7, iv: ive}); And this is the java code: final Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); final SecretKeySpec key = new SecretKeySpec(aesPassword().getBytes("UTF-8"), "AES"); cipher.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(aesIv().getBytes(

How to properly write JVM AES/CFB8 Encryption in Go

天涯浪子 提交于 2019-12-03 22:02:14
I wrote a little test in Kotlin to encrypt some text "Hello" using a Cipher instance with the algorithm "AES/CFB8/NoPadding". (minecraft stuff) And I am now attempting to do the same in Go, however I am unable to produce the same result. All the different methods I have tried always produce something different. These are the following threads/examples I've already looked through in order to get to this point. How to use rsa key pair for AES encryption and decryprion in golang https://play.golang.org/p/77fRvrDa4A Decrypt in Golang what was encrypted in Python AES CFB https://gist.github.com

C# equivalent of the Java SecretKeySpec for AES

纵然是瞬间 提交于 2019-12-03 22:00:07
I have following code written in java. I need C# equivalent for this. Key key = new SecretKeySpec(keyValue, "AES"); Cipher c = Cipher.getInstance("AES"); c.init(1, key); byte[] encVal = c.doFinal(Data.getBytes()); encryptedValue = new BASE64Encoder().encode(encVal); Here C# code equivalent in java. System.Text.UTF8Encoding UTF8 = new System.Text.UTF8Encoding(); AesManaged tdes = new AesManaged(); tdes.Key = UTF8.GetBytes(keyValue); tdes.Mode = CipherMode.ECB; tdes.Padding = PaddingMode.PKCS7; ICryptoTransform crypt = tdes.CreateEncryptor(); byte[] plain = Encoding.UTF8.GetBytes(text); byte[]

Application deadlocks when creating cipher streams from socket

落爺英雄遲暮 提交于 2019-12-03 21:59:13
I'm having problems encrypting and decrypting my streams between two sockets. ObjectInputStream oIn = new ObjectInputStream(new FileInputStream(new File("key"))); SecretKeySpec spec = (SecretKeySpec) oIn.readObject(); //'key' file was saved previously Cipher cEncrypt = Cipher.getInstance("AES"); cEncrypt.init(Cipher.ENCRYPT_MODE, spec); Cipher cDecrypt = Cipher.getInstance("AES"); cDecrypt.init(Cipher.DECRYPT_MODE, spec); //should have no problems here, I tried the ciphers out by encoding and decoding a String, works fine ObjectOutputStream objectOutputStream= new ObjectOutputStream(new

AES encryption & security flaw

不打扰是莪最后的温柔 提交于 2019-12-03 21:57:52
Check update#1 This logic is a candidate for a authentication procedure, done by simple HTTP requests: I'm sending: userName + encrypted_userName (encrypted_userName is actually the encrypted result of userName, done using AES & as key i use the md5 hash of the password). NOTE: I'm not sending the md5 hashed Password. on the server I'm comparing: encrypted_userName with own_encrypted_userName (since on server i have access to full info on user, i calculate own encrypted_userName). Question : is this a security flaw? Say bad guy captures full HTTP request, can he extract password from this 2

CryptoJs Encryption is not working in android

独自空忆成欢 提交于 2019-12-03 21:55:58
I have to implement encryption in android app. The web developer is using CryptoJs library. means Encryption alog is AES256 encryption. Both iOS and android platforms give different strings and iOS one is accepted at web.It should be same for sample strings. I am using below code snippets (there are 2 different diffrent functions): private void newEnc() { String secret = "LSC@SD2017@ps"; String cipherText = "{\"device_type\":\"iOS\",\"email\" : \"jhon@gmail.com\",\"device_id\" : \"14105DA4-CEE5-431E-96A2-2331CDA7F062\",\"password\" : \"123456\",\"device_token\" : \

AES encryption on Java side - decryption on PHP side and selecting a single key

这一生的挚爱 提交于 2019-12-03 21:55:23
I am using AES and I want to settle for a key which I can use on the Java side to encrypt a string, I hardcode the same key on php side and decrypt the string if the strings match I am authenticated to step inside. Following is my code in Java: public class AESencrp { private static final String ALGO = "AES"; private static final byte[] keyValue = new byte[] { 'T', 'h', 'e', 'B', 'e', 's', 't', 'S', 'e', 'c', 'r','e', 't', 'K', 'e', 'y' }; public static String encrypt(String Data) throws Exception { Key key = generateKey(); Cipher c = Cipher.getInstance(ALGO); c.init(Cipher.ENCRYPT_MODE, key);

How to decrypt a file in javascript which is encrypted by JAVA with AES

不打扰是莪最后的温柔 提交于 2019-12-03 21:54:24
I have encrypted JPG file in Java with AES256, but have no idea to decrypt the JPG file in javascript. Anyone has better idea? I'm struggling with it for 4days. byte[] ivBytes = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; String key = "1234567890123456789012345678901d"; AlgorithmParameterSpec ivSpec = new IvParameterSpec(ivBytes); SecretKeySpec newKey = new SecretKeySpec(key.getBytes("UTF-8"), "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(mode, newKey, ivSpec); InputStream input = null; OutputStream

Decrypt in PHP with Salt, password, and type?

谁说我不能喝 提交于 2019-12-03 21:54:19
When I run Crypto-JS's encrypt function, I am given the base64-encoded following: var crypted = CryptoJS.AES.encrypt("Message", "Secret Passphrase", {mode: CryptoJS.mode.CBC}).toString(); ==> "U2FsdGVkX19HKyOimD43Bl4ww/I40M+NQrscjti3ZnA=" How do I unencrypt this in PHP in the future? I have attempted using openSSL, mcrypt, etc, and nothin seems to work -- I guess I don't know how to deal with base64 encoding, salting, VI, and everything... Something goes wrong somewhere. JS // encrypt data with CryptoJS var crypted = CryptoJS.AES.encrypt("Message", "Secret Passphrase"); // get additional info