Diff
checker
Text
Text
Images
Documents
Excel
Folders
Legal
Enterprise
Desktop
Pricing
Sign in
Download Diffchecker Desktop
Compare text
Find the difference between two text files
Tools
History
Real-time editor
Hide unchanged lines
Disable line wrap
Layout
Split
Unified
Diff precision
Smart
Word
Char
Syntax highlighting
Choose syntax
Ignore
Transform text
Go to first change
Edit input
Diffchecker Desktop
The most secure way to run Diffchecker. Get the Diffchecker Desktop app: your diffs never leave your computer!
Get Desktop
C#Diff
Created
2 years ago
Diff never expires
Clear
Export
Share
Explain
2 removals
Lines
Total
Removed
Characters
Total
Removed
To continue using this feature, upgrade to
Diff
checker
Pro
View Pricing
64 lines
Copy
5 additions
Lines
Total
Added
Characters
Total
Added
To continue using this feature, upgrade to
Diff
checker
Pro
View Pricing
63 lines
Copy
using System;
using System;
using System.Security.Cryptography;
using System.Security.Cryptography;
using System.Text;
using System.Text;
class SSN
class SSN
{
{
public string EncryptString(string plainString, string keyString, string encryptionIV)
public string EncryptString(string plainString, string keyString, string encryptionIV)
{
{
Copy
Copied
Copy
Copied
byte[] key = Encoding.UTF8.GetBytes(keyString
);
byte[] key = Encoding.UTF8.GetBytes(keyString
.Substring(0, 16)
);
byte[] iv = Encoding.UTF8.GetBytes(encryptionIV
);
byte[] iv = Encoding.UTF8.GetBytes(encryptionIV
.Substring(0, 16)
);
using (Aes aesAlg = Aes.Create())
using (Aes aesAlg = Aes.Create())
{
{
Copy
Copied
Copy
Copied
aesAlg.KeySize = 128;
aesAlg.Key = key;
aesAlg.Key = key;
aesAlg.IV = iv;
aesAlg.IV = iv;
aesAlg.Mode = CipherMode.CBC;
aesAlg.Mode = CipherMode.CBC;
aesAlg.Padding = PaddingMode.None;
aesAlg.Padding = PaddingMode.None;
ICryptoTransform encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV);
ICryptoTransform encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV);
byte[] plainBytes = Encoding.UTF8.GetBytes(plainString);
byte[] plainBytes = Encoding.UTF8.GetBytes(plainString);
int blockSize = 16;
int blockSize = 16;
int paddingNeeded = blockSize - (plainBytes.Length % blockSize);
int paddingNeeded = blockSize - (plainBytes.Length % blockSize);
byte[] paddedBytes = new byte[plainBytes.Length + paddingNeeded];
byte[] paddedBytes = new byte[plainBytes.Length + paddingNeeded];
Array.Copy(plainBytes, paddedBytes, plainBytes.Length);
Array.Copy(plainBytes, paddedBytes, plainBytes.Length);
for (int i = plainBytes.Length; i < paddedBytes.Length; i++)
for (int i = plainBytes.Length; i < paddedBytes.Length; i++)
{
{
paddedBytes[i] = (byte)paddingNeeded;
paddedBytes[i] = (byte)paddingNeeded;
}
}
byte[] encryptedBytes = encryptor.TransformFinalBlock(paddedBytes, 0, paddedBytes.Length);
byte[] encryptedBytes = encryptor.TransformFinalBlock(paddedBytes, 0, paddedBytes.Length);
return Convert.ToBase64String(encryptedBytes);
return Convert.ToBase64String(encryptedBytes);
}
}
}
}
public string DecryptString(string encryptedString, string keyString, string encryptionIV)
public string DecryptString(string encryptedString, string keyString, string encryptionIV)
{
{
Copy
Copied
Copy
Copied
byte[] key = Encoding.UTF8.GetBytes(keyString
);
byte[] key = Encoding.UTF8.GetBytes(keyString
.Substring(0, 16)
);
byte[] iv = Encoding.UTF8.GetBytes(encryptionIV
);
byte[] iv = Encoding.UTF8.GetBytes(encryptionIV
.Substring(0, 16)
);
using (Aes aesAlg = Aes.Create())
using (Aes aesAlg = Aes.Create())
{
{
Copy
Copied
Copy
Copied
aesAlg.KeySize = 128;
aesAlg.Key = key;
aesAlg.Key = key;
aesAlg.IV = iv;
aesAlg.IV = iv;
aesAlg.Mode = CipherMode.CBC;
aesAlg.Mode = CipherMode.CBC;
aesAlg.Padding = PaddingMode.None;
aesAlg.Padding = PaddingMode.None;
ICryptoTransform decryptor = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV);
ICryptoTransform decryptor = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV);
byte[] encryptedBytes = Convert.FromBase64String(encryptedString);
byte[] encryptedBytes = Convert.FromBase64String(encryptedString);
byte[] decryptedBytes = decryptor.TransformFinalBlock(encryptedBytes, 0, encryptedBytes.Length);
byte[] decryptedBytes = decryptor.TransformFinalBlock(encryptedBytes, 0, encryptedBytes.Length);
int paddingByte = decryptedBytes[decryptedBytes.Length - 1];
int paddingByte = decryptedBytes[decryptedBytes.Length - 1];
int unpaddedLength = decryptedBytes.Length - paddingByte;
int unpaddedLength = decryptedBytes.Length - paddingByte;
return Encoding.UTF8.GetString(decryptedBytes, 0, unpaddedLength);
return Encoding.UTF8.GetString(decryptedBytes, 0, unpaddedLength);
}
}
}
}
}
}
Copy
Copied
Copy
Copied
Saved diffs
Original text
Open file
using System; using System.Security.Cryptography; using System.Text; class SSN { public string EncryptString(string plainString, string keyString, string encryptionIV) { byte[] key = Encoding.UTF8.GetBytes(keyString); byte[] iv = Encoding.UTF8.GetBytes(encryptionIV); using (Aes aesAlg = Aes.Create()) { aesAlg.KeySize = 128; aesAlg.Key = key; aesAlg.IV = iv; aesAlg.Mode = CipherMode.CBC; aesAlg.Padding = PaddingMode.None; ICryptoTransform encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV); byte[] plainBytes = Encoding.UTF8.GetBytes(plainString); int blockSize = 16; int paddingNeeded = blockSize - (plainBytes.Length % blockSize); byte[] paddedBytes = new byte[plainBytes.Length + paddingNeeded]; Array.Copy(plainBytes, paddedBytes, plainBytes.Length); for (int i = plainBytes.Length; i < paddedBytes.Length; i++) { paddedBytes[i] = (byte)paddingNeeded; } byte[] encryptedBytes = encryptor.TransformFinalBlock(paddedBytes, 0, paddedBytes.Length); return Convert.ToBase64String(encryptedBytes); } } public string DecryptString(string encryptedString, string keyString, string encryptionIV) { byte[] key = Encoding.UTF8.GetBytes(keyString); byte[] iv = Encoding.UTF8.GetBytes(encryptionIV); using (Aes aesAlg = Aes.Create()) { aesAlg.KeySize = 128; aesAlg.Key = key; aesAlg.IV = iv; aesAlg.Mode = CipherMode.CBC; aesAlg.Padding = PaddingMode.None; ICryptoTransform decryptor = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV); byte[] encryptedBytes = Convert.FromBase64String(encryptedString); byte[] decryptedBytes = decryptor.TransformFinalBlock(encryptedBytes, 0, encryptedBytes.Length); int paddingByte = decryptedBytes[decryptedBytes.Length - 1]; int unpaddedLength = decryptedBytes.Length - paddingByte; return Encoding.UTF8.GetString(decryptedBytes, 0, unpaddedLength); } } }
Changed text
Open file
using System; using System.Security.Cryptography; using System.Text; class SSN { public string EncryptString(string plainString, string keyString, string encryptionIV) { byte[] key = Encoding.UTF8.GetBytes(keyString.Substring(0, 16)); byte[] iv = Encoding.UTF8.GetBytes(encryptionIV.Substring(0, 16)); using (Aes aesAlg = Aes.Create()) { aesAlg.Key = key; aesAlg.IV = iv; aesAlg.Mode = CipherMode.CBC; aesAlg.Padding = PaddingMode.None; ICryptoTransform encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV); byte[] plainBytes = Encoding.UTF8.GetBytes(plainString); int blockSize = 16; int paddingNeeded = blockSize - (plainBytes.Length % blockSize); byte[] paddedBytes = new byte[plainBytes.Length + paddingNeeded]; Array.Copy(plainBytes, paddedBytes, plainBytes.Length); for (int i = plainBytes.Length; i < paddedBytes.Length; i++) { paddedBytes[i] = (byte)paddingNeeded; } byte[] encryptedBytes = encryptor.TransformFinalBlock(paddedBytes, 0, paddedBytes.Length); return Convert.ToBase64String(encryptedBytes); } } public string DecryptString(string encryptedString, string keyString, string encryptionIV) { byte[] key = Encoding.UTF8.GetBytes(keyString.Substring(0, 16)); byte[] iv = Encoding.UTF8.GetBytes(encryptionIV.Substring(0, 16)); using (Aes aesAlg = Aes.Create()) { aesAlg.Key = key; aesAlg.IV = iv; aesAlg.Mode = CipherMode.CBC; aesAlg.Padding = PaddingMode.None; ICryptoTransform decryptor = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV); byte[] encryptedBytes = Convert.FromBase64String(encryptedString); byte[] decryptedBytes = decryptor.TransformFinalBlock(encryptedBytes, 0, encryptedBytes.Length); int paddingByte = decryptedBytes[decryptedBytes.Length - 1]; int unpaddedLength = decryptedBytes.Length - paddingByte; return Encoding.UTF8.GetString(decryptedBytes, 0, unpaddedLength); } } }
Find difference