Created
August 24, 2022 16:31
-
-
Save joshjohanning/355380de17e0ff507f71d66bf4ec8123 to your computer and use it in GitHub Desktop.
sample vulnerable .NET C# code for CodeQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Security.Cryptography; | |
class WeakEncryption | |
{ | |
public static byte[] encryptString() | |
{ | |
SymmetricAlgorithm serviceProvider = new DESCryptoServiceProvider(); | |
byte[] key = { 16, 22, 240, 11, 18, 150, 192, 21 }; | |
serviceProvider.Key = key; | |
ICryptoTransform encryptor = serviceProvider.CreateEncryptor(); | |
String message = "Hello World"; | |
byte[] messageB = System.Text.Encoding.ASCII.GetBytes(message); | |
return encryptor.TransformFinalBlock(messageB, 0, messageB.Length); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment