So this is my decrypt function:
def decrypt(value):
key = b'1111111111111111'
cipher = AES.new(key, AES.MODE_ECB)
msg = cipher.decrypt(base64.b64decode(value))
return msg
And i think I am missing something here, because when i give it a string to decrypt it also adds some strange characters :
Example : hey\r\r\r\r\r\r\r\r\r\r\r\r\r
What am i doing wrong?
P.S. I am using google app engine and this lib from Crypto.Cipher import AES
EDIT :
private static final String ALGO = "AES";
private static final byte[] keyValue = new byte[] { '1', '1', '1', '1', '1', '1', '1', '1', '1','1', '1', '1','1','1','1','1' };
public static String encrypt(String Data) throws Exception {
Key key = generateKey();
Cipher c = Cipher.getInstance(ALGO);
c.init(Cipher.ENCRYPT_MODE, key);
byte[] encVal = c.doFinal(Data.getBytes());
// String encryptedValue = new BASE64Encoder().encode(encVal);
byte[] decoded = Base64.encodeBase64(encVal);
return (new String(decoded, "UTF-8") + "\n");
}
private static Key generateKey() throws Exception {
Key key = new SecretKeySpec(keyValue, ALGO);
return key;
}