Diff
checker
텍스트
텍스트
이미지
문서
Excel
폴더
Legal
Enterprise
데스크톱
요금제
로그인
데스크톱 앱 다운로드
텍스트 비교
두 텍스트 파일의 차이점을 찾아보세요
도구
기록
실시간 편집
변경 없는 행 숨기기
줄바꿈 비활성화
레이아웃
나란히 보기
합쳐 보기
비교 단위
스마트
단어
글자
구문 강조
언어 선택
제외
텍스트 변환
첫 변경으로
수정
Diffchecker Desktop
가장 안전하게 Diffchecker를 사용하는 방법. 데스크톱 앱을 사용하면 비교 데이터가 외부로 전송되지 않습니다!
데스크톱 앱 받기
C#Diff
생성일
2년 전
비교 결과 만료 없음
초기화
내보내기
공유
설명
2 삭제
행
총
삭제
글자
총
삭제
이 기능을 계속 사용하려면 업그레이드해 주세요
Diff
checker
Pro
요금제 보기
64 행
복사
5 추가
행
총
추가
글자
총
추가
이 기능을 계속 사용하려면 업그레이드해 주세요
Diff
checker
Pro
요금제 보기
63 행
복사
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)
{
{
복사
복사됨
복사
복사됨
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())
{
{
복사
복사됨
복사
복사됨
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)
{
{
복사
복사됨
복사
복사됨
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())
{
{
복사
복사됨
복사
복사됨
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);
}
}
}
}
}
}
복사
복사됨
복사
복사됨
저장된 비교 결과
원본
파일 열기
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); } } }
수정본
파일 열기
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); } } }
비교하기