[FIX] Проблемы с кодировкой в SecurityHelper

Closes #412
This commit is contained in:
Zaxar163 2021-07-21 19:14:57 +03:00
parent 7ad308cc23
commit dfa2b042e4
No known key found for this signature in database
GPG key ID: BC54673329B5017D

View file

@ -488,12 +488,12 @@ public static Cipher newRSAEncryptCipher(RSAPublicKey publicKey) {
//AES //AES
public static byte[] encrypt(String seed, byte[] cleartext) throws Exception { public static byte[] encrypt(String seed, byte[] cleartext) throws Exception {
byte[] rawKey = getAESKey(seed.getBytes()); byte[] rawKey = getAESKey(IOHelper.encode(seed));
return encrypt(rawKey, cleartext); return encrypt(rawKey, cleartext);
} }
public static byte[] encrypt(String seed, String cleartext) throws Exception { public static byte[] encrypt(String seed, String cleartext) throws Exception {
return encrypt(seed, cleartext.getBytes()); return encrypt(seed, IOHelper.encode(cleartext));
} }
public static byte[] getAESKey(byte[] seed) throws Exception { public static byte[] getAESKey(byte[] seed) throws Exception {
@ -520,7 +520,7 @@ public static byte[] decrypt(byte[] raw, byte[] encrypted) throws Exception {
} }
public static byte[] decrypt(String seed, byte[] encrypted) throws Exception { public static byte[] decrypt(String seed, byte[] encrypted) throws Exception {
return decrypt(getAESKey(seed.getBytes()), encrypted); return decrypt(getAESKey(IOHelper.encode(seed)), encrypted);
} }
public static byte[] fromHex(String hexString) { public static byte[] fromHex(String hexString) {