parent
94267db59b
commit
beb7bbf7cf
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,31 @@ |
||||
/* |
||||
* This file is part of FYReader. |
||||
* FYReader is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FYReader is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with FYReader. If not, see <https://www.gnu.org/licenses/>.
|
||||
* |
||||
* Copyright (C) 2020 - 2022 fengyuecanzhu |
||||
*/ |
||||
|
||||
package xyz.fycz.dynamic; |
||||
|
||||
/** |
||||
* Generated code from StringFog gradle plugin. Do not modify! |
||||
*/ |
||||
public final class StringFog { |
||||
private static final StringFogImpl IMPL = new StringFogImpl(); |
||||
|
||||
public static String decrypt(byte[] value, byte[] key) { |
||||
return IMPL.decrypt(value, key); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,59 @@ |
||||
/* |
||||
* This file is part of FYReader. |
||||
* FYReader is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* FYReader is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with FYReader. If not, see <https://www.gnu.org/licenses/>.
|
||||
* |
||||
* Copyright (C) 2020 - 2022 fengyuecanzhu |
||||
*/ |
||||
|
||||
package xyz.fycz.dynamic; |
||||
|
||||
import java.nio.charset.StandardCharsets; |
||||
|
||||
/** |
||||
* StringFog xor encrypt and decrypt implementation. |
||||
* |
||||
* @author Megatron King |
||||
* @since 2018/9/2 14:34 |
||||
*/ |
||||
public final class StringFogImpl { |
||||
|
||||
public byte[] encrypt(String data, byte[] key) { |
||||
return xor(data.getBytes(StandardCharsets.UTF_8), key); |
||||
} |
||||
|
||||
public String decrypt(byte[] data, byte[] key) { |
||||
return new String(xor(data, key), StandardCharsets.UTF_8); |
||||
} |
||||
|
||||
public boolean shouldFog(String data) { |
||||
return true; |
||||
} |
||||
|
||||
private static byte[] xor(byte[] data, byte[] key) { |
||||
int len = data.length; |
||||
int lenKey = key.length; |
||||
int i = 0; |
||||
int j = 0; |
||||
while (i < len) { |
||||
if (j >= lenKey) { |
||||
j = 0; |
||||
} |
||||
data[i] = (byte) (data[i] ^ key[j]); |
||||
i++; |
||||
j++; |
||||
} |
||||
return data; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue