private string EncryptShaToDB(string strSource) { try { return(ServerHashEncryption.EncryptString(strSource, EncryptionMode.SHA512V00Hex)); } catch { return(strSource); } }
private string GenerateToken(LoggingServerInfo info) { string strCode = string.Format("{0}{1}", mToken, info.HostAddress); return(ServerHashEncryption.EncryptString(strCode, EncryptionMode.SHA256V00Hex)); }
void BtnEncrypt_Click(object sender, RoutedEventArgs e) { try { var typeItem = ListBoxType.SelectedItem as EncryptionTypeItem; var modeItem = ComboMode.SelectedItem as EncryptionModeItem; var encItem = ListBoxEncoding.SelectedItem as EncryptionEncodingItem; if (typeItem == null || modeItem == null || encItem == null) { return; } string strSource = TxtSource.Text; string strReturn = string.Empty; //string strTemp; int mode = (int)modeItem.Mode; int type = mode / 1000; Encoding encoding = encItem.Encoding; switch (type) { case 1: //do //{ // if (strSource.Length > 128) // { // strTemp = strSource.Substring(0, 128); // strSource = strSource.Substring(128, strSource.Length - 128); // } // else // { // strTemp = strSource; // strSource = string.Empty; // } // if (typeItem.Value == 1) // { // strReturn += ClientAESEncryption.EncryptString(strTemp, modeItem.Mode, encoding); // } // else // { // strReturn += ServerAESEncryption.EncryptString(strTemp, modeItem.Mode, encoding); // } //} while (strSource.Length > 0); if (typeItem.Value == 1) { strReturn += ClientAESEncryption.EncryptString(strSource, modeItem.Mode, encoding); } else { strReturn += ServerAESEncryption.EncryptString(strSource, modeItem.Mode, encoding); } break; case 2: case 3: if (typeItem.Value == 1) { strReturn += ClientHashEncryption.EncryptString(strSource, modeItem.Mode, encoding); } else { strReturn += ServerHashEncryption.EncryptString(strSource, modeItem.Mode, encoding); } break; default: ShowErrorMessage(string.Format("EncryptMode invalid.\t{0}", modeItem.Mode)); return; } AppendMessage(strReturn); } catch (Exception ex) { ShowErrorMessage(ex.Message); } }