在c#中使用IDPF标准混淆字体文件
我必须使用 IDPF 算法对字体文件 - .otf 和 .ttf 文件进行混淆和反混淆。我有这段代码来混淆java中的文件
public void serialize(OutputStream out) throws IOException {
try {
byte[] buffer = new byte[4096];
int len;
InputStream in = source.getInputStream();
boolean first = true;
while ((len = in.read(buffer)) > 0) {
if( first && mask != null ) {
first = false;
for( int i = 0 ; i < 1040 ; i++ ) {
buffer[i] = (byte)(buffer[i] ^ mask[i%mask.length]);
}
}
out.write(buffer, 0, len);
}
} catch (IOException e) {
e.printStackTrace();
}
out.close();
}
,是否需要加密密钥,因为在此代码中未使用加密密钥。请指导我如何开始
I have to obfuscate and de-obfuscate font files- .otf and .ttf files with IDPF algorithm. i have got this code to obfuscate a file in java
public void serialize(OutputStream out) throws IOException {
try {
byte[] buffer = new byte[4096];
int len;
InputStream in = source.getInputStream();
boolean first = true;
while ((len = in.read(buffer)) > 0) {
if( first && mask != null ) {
first = false;
for( int i = 0 ; i < 1040 ; i++ ) {
buffer[i] = (byte)(buffer[i] ^ mask[i%mask.length]);
}
}
out.write(buffer, 0, len);
}
} catch (IOException e) {
e.printStackTrace();
}
out.close();
}
is there any requirement of encryption key as in this code encryption key is not used. please guide me to how to get started
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它不需要加密密钥,因为它不是加密文件,而是对其进行混淆。如果您想加密文件,然后解密它,
.net
框架中有很多内置类可用于此目的,并且它们采用加密密钥。看一下这个命名空间。它包含许多类允许您使用不同的算法来加密和解密数据。
此外,永远不要编写自己的加密代码,因为它几乎肯定是可破解的(除非您是天才,非常认真,并且在接下来的一两年内没有其他更重要的事情要做)。
It doesn't need an encryption key because it's not encrypting the file, it's obfuscating it. If you want to encrypt a file, and then decrypt it there are quite a few built-in classes in the
.net
framework for this exact purpose, and they take an encryption key.Take a look at this namespace.It contains many classes that allow you to use different algorithms for encrypting and decrypting data.
Furthermore, never write your own encryption code, as it will almost certainly be breakable (unless you're a genius, very conscientious, and have nothing else more important to do for the next year or two).