복호화 부분은 here이라고 대답합니다.
C 번호
public static string EncryptString(string message, string KeyString, string IVString)
{
byte[] Key = ASCIIEncoding.UTF8.GetBytes(KeyString);
byte[] IV = ASCIIEncoding.UTF8.GetBytes(IVString);
string encrypted = null;
RijndaelManaged rj = new RijndaelManaged();
rj.Key = Key;
rj.IV = IV;
rj.Mode = CipherMode.CBC;
try
{
MemoryStream ms = new MemoryStream();
using (CryptoStream cs = new CryptoStream(ms, rj.CreateEncryptor(Key, IV), CryptoStreamMode.Write))
{
using (StreamWriter sw = new StreamWriter(cs))
{
sw.Write(message);
sw.Close();
}
cs.Close();
}
byte[] encoded = ms.ToArray();
encrypted = Convert.ToBase64String(encoded);
ms.Close();
}
catch (CryptographicException e)
{
Console.WriteLine("A Cryptographic error occurred: {0}", e.Message);
return null;
}
catch (UnauthorizedAccessException e)
{
Console.WriteLine("A file error occurred: {0}", e.Message);
return null;
}
catch (Exception e)
{
Console.WriteLine("An error occurred: {0}", e.Message);
}
finally
{
rj.Clear();
}
return encrypted;
}
디코딩베이스 64 :의
/// <summary>
/// The method create a Base64 encoded string from a normal string.
/// </summary>
/// <param name="toEncode">The String containing the characters to encode.</param>
/// <returns>The Base64 encoded string.</returns>
public static string EncodeTo64(string toEncode)
{
byte[] toEncodeAsBytes
= System.Text.Encoding.Unicode.GetBytes(toEncode);
string returnValue
= System.Convert.ToBase64String(toEncodeAsBytes);
return returnValue;
}
/// <summary>
/// The method to Decode your Base64 strings.
/// </summary>
/// <param name="encodedData">The String containing the characters to decode.</param>
/// <returns>A String containing the results of decoding the specified sequence of bytes.</returns>
public static string DecodeFrom64(string encodedData)
{
byte[] encodedDataAsBytes
= System.Convert.FromBase64String(encodedData);
string returnValue =
System.Text.Encoding.Unicode.GetString(encodedDataAsBytes);
return returnValue;
}
중복 가능성 [Rijndael을 256 암호화/C# 및 PHP 사이 해독? (HTTP//stackoverflow.com/questions/3431950/rijndael-256-encrypt-decrypt-betwee n-c-sharp-and-php) – Shai
md5는 암호화 할 수 있습니까? – Ismael
아이들이 이런 모든 암호화/해시 메소드를 중첩하는 것을 멈추게 할 수 있습니다. 일반적인 사이트 암호를 사용하여 암호를 암호화하기 위해'mcrypt'와 같은 것을 사용하십시오 (높은 엔트로피, 좋은 보안을 원한다면 복잡합니다). 키의 md5는 처음부터 좋은 키만큼 안전하지 못합니다. – deed02392