Skip to content

Instantly share code, notes, and snippets.

@vivami
Last active August 31, 2018 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vivami/bdeb32458db2c33655cb46470bd7fdd9 to your computer and use it in GitHub Desktop.
Save vivami/bdeb32458db2c33655cb46470bd7fdd9 to your computer and use it in GitHub Desktop.
Encrypt .NET assembly to string
String path = args[0];
key = getRandomKey();
String filename = Path.GetFileNameWithoutExtension(path).ToString();
String obfuscatedBin = obfuscateBinary(path);
private String obfuscateBinary(String file) {
byte[] assemblyBytes = fileToByteArray(@file);
byte[] encryptedAssembly = encrypt(assemblyBytes, key);
return System.Convert.ToBase64String(encryptedAssembly);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment