Diff
checker
Texte
Texte
Images
Documents
Excel
Dossiers
Legal
Enterprise
Application de bureau
Prix
Se connecter
Télécharger Diffchecker Desktop
Comparer le texte
Trouver la différence entre deux fichiers texte
Outils
Historique
Éditeur live
Cacher identiques
Sans retour à la ligne
Vue
Divisé
Unifié
Niveau de précision
Intelligent
Mot
Caractère
Coloration syntaxique
Choisir la syntaxe
Ignorer
Transformer le texte
Aller au premier écart
Modifier l'entrée
Diffchecker Desktop
La façon la plus sécurisée d'utiliser Diffchecker. Obtenez l'application Diffchecker Desktop : vos diffs ne quittent jamais votre ordinateur !
Obtenir Desktop
C#Diff
Créé
il y a 2 ans
Le diff n'expire jamais
Effacer
Exporter
Partager
Expliquer
2 suppressions
Lignes
Total
Supprimé
Caractères
Total
Supprimé
Pour continuer à utiliser cette fonctionnalité, passez à
Diff
checker
Pro
Voir les prix
64 lignes
Copier tout
5 ajouts
Lignes
Total
Ajouté
Caractères
Total
Ajouté
Pour continuer à utiliser cette fonctionnalité, passez à
Diff
checker
Pro
Voir les prix
63 lignes
Copier tout
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)
{
{
Copier
Copié
Copier
Copié
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())
{
{
Copier
Copié
Copier
Copié
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)
{
{
Copier
Copié
Copier
Copié
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())
{
{
Copier
Copié
Copier
Copié
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);
}
}
}
}
}
}
Copier
Copié
Copier
Copié
Différences enregistrées
Texte d'origine
Ouvrir un fichier
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); } } }
Texte modifié
Ouvrir un fichier
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); } } }
Trouver la différence