/// <summary> /// 복호화 Decrypt - Encrypt_HexString To string /// </summary> /// <param name="input"></param> /// <param name="key_HexString"></param> /// <param name="iv_HexString"></param> /// <returns></returns> public static string Decrypt_String(string input, string key_HexString, string iv_HexString) { string HexString = String_Convertor.ByteHexToHexString(AES128.Decrypt(String_Convertor.HexStringToByteHex(input), String_Convertor.HexStringToByteHex(key_HexString), String_Convertor.HexStringToByteHex(iv_HexString))); byte[] bytes_output = String_Convertor.HexStringToByteHex(HexString); return(System.Text.Encoding.UTF8.GetString(bytes_output)); }
/// <summary> /// 입력된 값으로 userpermit을 생성하여 반환 /// </summary> /// <param name="mid"></param> /// <param name="mkey"></param> /// <param name="hwid"></param> /// <param name="iv"></param> /// <returns></returns> public static string GetUserpermit(string mid, string mkey, string hwid, string iv = "00000000000000000000000000000000") { //String To HEX byte[] IV = String_Convertor.HexStringToByteHex(iv); byte[] M_ID = String_Convertor.HexStringToByteHex(mid); byte[] M_KEY = String_Convertor.HexStringToByteHex(mkey); byte[] HW_ID = String_Convertor.HexStringToByteHex(hwid); //암호화 //Encrypred HW ID = Aes(HW_ID, M_KEY, IV) byte[] Encrypred_HW_ID = AES128.Encrypt(HW_ID, M_KEY, IV); //String To HEX string strEncrypred_HW_ID = String_Convertor.ByteHexToHexString(Encrypred_HW_ID); //Checksum = CRC32(EncrypredHWID) string checksum = CRC32.StringToCRC32(strEncrypred_HW_ID).ToString("X2"); return(strEncrypred_HW_ID + checksum + mid); }
/// <summary> /// 암호화 Encrypt - string To Decrypt_String /// </summary> /// <param name="input"></param> /// <param name="key_HexString"></param> /// <param name="iv_HexString"></param> /// <returns></returns> public static string Encrypt_String(string input, string key_HexString, string iv_HexString) { byte[] bytes_input = System.Text.Encoding.UTF8.GetBytes(input); input = String_Convertor.ByteHexToHexString(bytes_input); return(String_Convertor.ByteHexToHexString(AES128.Encrypt(String_Convertor.HexStringToByteHex(input), String_Convertor.HexStringToByteHex(key_HexString), String_Convertor.HexStringToByteHex(iv_HexString)))); }