RyeolStringEncrypter.zip

This is new string encrypters that is the upgrade of the previous string encrypters to support AES-256. Though PHP and Java are not available, you can download a COM dll (32/64 bit) and a C# class.

The string encrypters take two strings, a key and an initialization vector. To be used as an AES key, the key string is converted into UTF-8, and then is hashed by MD5 or SHA2-256.

Similarly, the IV is hashed by MD5.

The input string is converted into UTF-8, and then is encrypted using 128-bits or 256-bits AES in Cipher Block Chaining(CBC) with PKCS7 padding. The AES key size depends on the size of the hash for the key string. For example, if the hash is SHA2-256, 256-bits AES is used. Base64 is used for the encrypted binary.

The following code is an example of using the string encrypter in C#. The StringEncrypter class is implemented in the StringEncrypter.cs file.

/*
 *  C#
 */
using Ryeol.Security.Cryptography;
...
const string key = "This is a secret key.";
const string iv = "This is an initialization vector.";

// Creates an instance.
StringEncrypter encrypter = new StringEncrypter(key, iv);

// Sets the key hash algorithm. MD5 and SHA2-256 are supported.
// In this case the hash size is 256 bits, AES-256 is used.
encrypter.KeyHashAlgorithm = StringEncrypterKeyHashAlgorithm.SHA2_256;

// Encrypts a string.
string encrypted = encrypter.Encrypt("Test sample");

// Decrypts the encrypted string.
string decrypted = encrypter.Decrypt(encrypted);

The following code shows how to use the string encrypter in ASP(VBScript). Since ASP doesn't support built-in AES algorithm, you need to install the RyeolStringEncrypter.dll file which is a COM dll based on XySSL 0.8.
(You also need to install the Visual C++ Redistributable for Visual Studio 2012.)
'
'  ASP (VBScript)
' 
Const conKey = "This is a secret key."
Const conIV = "This is an initialization vector."

' Creates an instance.
Set objEncrypter = Server.CreateObject("Ryeol.StringEncrypter")

objEncrypter.Key = conKey
objEncrypter.IV = conIV

' Sets the key hash algorithm. MD5 and SHA2-256 are supported.
' In this case the hash size is 256 bits, AES-256 is used.
objEncrypter.KeyHashAlgorithm = "SHA2-256"

' Encrypts a string.
strEncrypted = objEncrypter.Encrypt("Test sample")

' Decrypts the encrypted string.
strDecrypted = objEncrypter.Decrypt(strEncrypted)



Release Note

June 7, 2013
The C# StringEncrypter has changed to create a hash implementation by using the Create method to support Windows XP.

December 10, 2012
Initial release.
신고

비주얼 스튜디오에서 Add Service Reference 로 프록시를 만들 때 다음과 같은 에러가 발생할 수 있습니다.

메타데이터에 확인할 수 없는 참조가 포함되었습니다.

이 경우 서비스에 시리얼라이저블 될 수 없는 형식이 있는지 찾아봐야 합니다.
DataContract 나 Serializable 특성이 없는 형식을 찾으면 됩니다.


참고자료:
   http://ko.w3support.net/index.php?db=so&id=762322


신고

소스 관리의 편의 문제로 현재 주석은 영어로 작성되어 있습니다.

MVVM 패턴에서 RadioButton을 사용하는 것은 생각보다 까다로울 수 있습니다.
예를 들어, 다음처럼 2개의 RadioButton을 사용하는 간단한 UI를 만든다고 가정해 보겠습니다.

2개의 RadioButton을 사용하는 아주 간단한 UI.


보통 맨 처음의 시도는 뷰를 다음처럼 만드는 것입니다:
...
<GroupBox Header="I love">
    <StackPanel>
        <RadioButton IsChecked="{Binding IsPeaceLover}">Peace</RadioButton>
        <RadioButton>Earth</RadioButton>
    </StackPanel>
</GroupBox>
...
그리고 뷰모델은 이렇게 할 것입니다:
class UserViewModel : ViewModelBase
{
    bool isPeaceLover = true;

    public bool IsPeaceLover
    {
        get { return this.isPeaceLover; }
        set
        {
            if (this.isPeaceLover == value)
                return;

            this.isPeaceLover = value;
            OnPropertyChanged("IsPeaceLover");
        }
    }
    ...
}
그러나 이미 알고 계시듯이 이렇게 작성하면 제대로 동작하지 않습니다.
구글 검색에서는 이 문제를 해결하는 여러 방법들을 소개하고 있지만, MVVM에 적합한 방법은 없더군요. (코드 비하인드를 안쓰는 방법) 
그래서 나름 고민 끝에 나온 결론은 뷰를 다음처럼 작성하는 것이었습니다:
...
<GroupBox Header="I love">
    <StackPanel>
        <RadioButton IsChecked="{Binding IsPeaceLover}">Peace</RadioButton>
        <RadioButton IsChecked="{Binding IsEarthLover}">Earth</RadioButton>
    </StackPanel>
</GroupBox>
...
그리고 뷰모델은 이렇게 작성합니다:
class UserViewModel : ViewModelBase
{
    bool isPeaceLover = true;

    public bool IsPeaceLover
    {
        get { return this.isPeaceLover; }
        set
        {
            if (this.isPeaceLover == value)
                return;

            this.isPeaceLover = value;
            OnPropertyChanged("IsPeaceLover", "IsEarthLover");
        }
    }

    public bool IsEarthLover
    {
        get { return !IsPeaceLover; }
        set { IsPeaceLover = !value; }
    }
    ...
}
만약 선택 항목이 2개 이상인 경우에는 다음처럼 응용해서 작성하시면 됩니다:
public enum Priority
{
    Low,
    Middle,
    High,
}

class JobViewModel : ViewModelBase
{
    Priority priority = Priority.Low;

    public Priority Priority
    {
        get { return this.priority; }
        set
        {
            if (this.priority == value)
                return;

            this.priority = value;
            OnPropertyChanged("Priority"
                     , "IsLowPriority", "IsMiddlePriority", "IsHighPriority");
        }
    }

    public bool IsLowPriority
    {
        get { return Priority == Priority.Low; }
        set { Priority = value ? Priority.Low : Priority; }
    }

    public bool IsMiddlePriority
    {
        get { return Priority == Priority.Middle; }
        set { Priority = value ? Priority.Middle : Priority; }
    }

    public bool IsHighPriority
    {
        get { return Priority == Priority.High; }
        set { Priority = value ? Priority.High : Priority; }
    }
}
...
<GroupBox Header="Priority">
    <StackPanel>
        <RadioButton IsChecked="{Binding IsLowPriority}">Low</RadioButton>
        <RadioButton IsChecked="{Binding IsMiddlePriority}">Middle</RadioButton>
        <RadioButton IsChecked="{Binding IsHighPriority}">High</RadioButton>
    </StackPanel>
</GroupBox>
...


신고

티스토리 툴바