本文整理汇总了C#中Crypto类的典型用法代码示例。如果您正苦于以下问题:C# Crypto类的具体用法?C# Crypto怎么用?C# Crypto使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Crypto类属于命名空间,在下文中一共展示了Crypto类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetDecryptedJArrayParams
private static JArray GetDecryptedJArrayParams(HttpContext context)
{
string message = context.Request.Params[METHOD_PARAMS.Message];
string passPhrase = AES_PASS_PHRASE;
Crypto crypto = new Crypto(passPhrase);
string clearData = crypto.DecryptFromBase64(message);
JArray jsonArray = (JArray)JsonConvert.DeserializeObject(clearData);
if (jsonArray.Count < 1)
throw new Exception("Decrypted parameter list contains no paramater. ");
return jsonArray;
}
开发者ID:williamyip,项目名称:ForGood,代码行数:11,代码来源:Helper.cs
示例2: SetUserAuthCookie
private void SetUserAuthCookie()
{
Crypto crypto = new Crypto();
FormsAuthenticationTicket Ticket = new FormsAuthenticationTicket(1, Session.SessionID, DateTime.Now, DateTime.Now.AddMinutes(FormsAuthentication.Timeout.Minutes), false, crypto.EncryptString(JsonConvert.SerializeObject(Session["Credencial"])));
string CookieString = FormsAuthentication.Encrypt(Ticket);
HttpCookie Cookie = new HttpCookie(FormsAuthentication.FormsCookieName, CookieString);
Cookie.Expires = Ticket.Expiration;
Cookie.Path = FormsAuthentication.FormsCookiePath;
Cookie.HttpOnly = true;
System.Web.HttpContext.Current.Response.Cookies.Add(Cookie);
}
开发者ID:bhrugu4me,项目名称:MyFan,代码行数:11,代码来源:UserController.cs
示例3: SolderSqlHandler
public SolderSqlHandler()
{
Crypto crypto = new Crypto();
ConfigHandler ch = new ConfigHandler();
try
{
String s = ch.GetConfig("mysqlPassword");
if (String.IsNullOrWhiteSpace(s))
{
ch.SetConfig("mysqlPassword", crypto.EncryptToString("password"));
}
}
catch (Exception e)
{
Debug.WriteLine(e.Message);
Debug.WriteLine(e.InnerException.ToString());
ch.SetConfig("mysqlPassword", crypto.EncryptToString("password"));
}
var password = crypto.DecryptString(ch.GetConfig("mysqlPassword"));
var username = ch.GetConfig("mysqlUsername");
var address = ch.GetConfig("mysqlAddress");
_database = ch.GetConfig("mysqlDatabase");
_prefix = ch.GetConfig("mysqlPrefix");
_connectionString = String.Format("address={0};username={1};password={2};database={3}", address, username, password, _database);
}
开发者ID:ReArmedHalo,项目名称:TechnicSolderHelper,代码行数:25,代码来源:SolderSQLHandler.cs
示例4: Sha1Bytes_ReturnsCorrectHash
public void Sha1Bytes_ReturnsCorrectHash()
{
byte[] bytes = new Crypto().Sha1Bytes("hello world");
String hex = BitConverter.ToString(bytes);
String actual = hex.Replace("-", "");
Assert.AreEqual("2AAE6C35C94FCFB415DBE95F408B9CE91EE846ED", actual);
}
开发者ID:khorvat,项目名称:braintree_dotnet,代码行数:7,代码来源:CryptoTest.cs
示例5: MD5Crypto
public static string MD5Crypto(string text)
{
Byte[] dataToHash = new Crypto().ConvertStringToByteArrayASCII(text);
byte[] hashValue = (new MD5CryptoServiceProvider()).ComputeHash(dataToHash);
//return hashValue.ToString();
return BitConverter.ToString(hashValue);
}
开发者ID:senseicz,项目名称:Galerie-KusVola,代码行数:7,代码来源:Crypto.cs
示例6: Login
public ActionResult Login(Login login)
{
if (ModelState.IsValid)
{
ConnectUpdate udb = new ConnectUpdate();
hackathonunitecEntities db = udb.getDB();
Crypto crypto = new Crypto(login.password);
string password = crypto.GetHash();
var users = db.user.Where(p => p.email == login.email && p.password == password );
int coun = users.Count();
if (users.Count() == 1)
{
Session["email"] = login.email;
return View("Index");
}
else
{
ModelState.AddModelError("email", "email or Password not valid");
return View();
}
}
else
{
return View();
}
}
开发者ID:camilorivera,项目名称:gamenhack,代码行数:28,代码来源:HomeController.cs
示例7: btnGuardarConexion_ItemClick
private void btnGuardarConexion_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
if (txtServer.Text != "" && txtDB.Text != "" && txtLogin.Text != "" && txtPassword.Text != "")
{
{
SqlConnection conn = new SqlConnection("Data Source=" + txtServer.Text + ";Initial Catalog=" + txtDB.Text + ";Persist Security Info=True;User ID=" + txtLogin.Text + ";Password=" + txtPassword.Text);
try
{
MSRegistro RegIn = new MSRegistro();
Crypto EncriptarTexto = new Crypto();
conn.Open();
RegIn.SaveSetting("AvoTrace", "ConexionSQL", "Server", EncriptarTexto.Encriptar(txtServer.Text));
RegIn.SaveSetting("AvoTrace", "ConexionSQL", "DBase", EncriptarTexto.Encriptar(txtDB.Text));
RegIn.SaveSetting("AvoTrace", "ConexionSQL", "User", EncriptarTexto.Encriptar(txtLogin.Text));
RegIn.SaveSetting("AvoTrace", "ConexionSQL", "Password", EncriptarTexto.Encriptar(txtPassword.Text));
RegIn.SaveSetting("AvoTrace", "ConexionSQL", "Sucursal", EncriptarTexto.Encriptar(Convert.ToString(cmbSucursal.SelectedValue)));
RegIn.SaveSetting("AvoTrace", "ConexionSQL", "Estacion", EncriptarTexto.Encriptar(Convert.ToString(cbEstacion.SelectedValue)));
MessageBox.Show("Se Grabaron los Datos Del Servidor Principal Con Exito");
this.Close();
}
catch (Exception ex)
{
MessageBox.Show("Error Descripcion: " + ex);
}
}
}
else
{
MessageBox.Show("Faltan Datos para la Conexion Principal");
}
}
开发者ID:24SieteConsulting,项目名称:AvoTrace,代码行数:31,代码来源:FrmConexion.cs
示例8: GetAuthenticationData
public Token GetAuthenticationData()
{
var cookie = HttpContext.Current.Request.Cookies[WebAuthSettings.CookieKey];
if (cookie == null)
{
throw new WebAuthCookieNotFoundException();
}
var crypto = new Crypto();
var tokenJs = crypto.DecryptStringAES(cookie.Value, WebAuthSettings.EncryptionSharedSecret);
var token = (new JavaScriptSerializer()).Deserialize<Token>(tokenJs);
if (token.Expiry < token.Time)
{
throw new TokenExpiredException();
}
if (HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"] != token.UserIPAddress)
{
throw new InvalidIPException();
}
return token;
}
开发者ID:asifashraf,项目名称:Radmade-Portable-Framework,代码行数:27,代码来源:Auth.cs
示例9: doUserAndPassword
public static void doUserAndPassword()
{
string droneshareusername = MainV2.getConfig("droneshareusername");
InputBox.Show("Username", "Username", ref droneshareusername);
MainV2.config["droneshareusername"] = droneshareusername;
string dronesharepassword = MainV2.getConfig("dronesharepassword");
if (dronesharepassword != "")
{
try
{
// fail on bad entry
var crypto = new Crypto();
dronesharepassword = crypto.DecryptString(dronesharepassword);
}
catch { }
}
InputBox.Show("Password", "Password", ref dronesharepassword,true);
var crypto2 = new Crypto();
string encryptedpw = crypto2.EncryptString(dronesharepassword);
MainV2.config["dronesharepassword"] = encryptedpw;
}
开发者ID:jxnkwlp,项目名称:MissionPlanner,代码行数:29,代码来源:droneshare.cs
示例10: Acceptbutton_Click
private void Acceptbutton_Click(object sender, EventArgs e)
{
if (String.IsNullOrWhiteSpace(Username.Text) || String.IsNullOrWhiteSpace(Password.Text) || String.IsNullOrWhiteSpace(Host.Text))
{
MessageBox.Show("Please fill out all values");
}
else
{
String url = Host.Text;
if (Uri.IsWellFormedUriString(url, UriKind.Absolute))
{
Crypto crypto = new Crypto();
ConfigHandler ch = new ConfigHandler();
ch.SetConfig("ftpUserName", Username.Text);
ch.SetConfig("ftpUrl", url);
ch.SetConfig("ftpPassword", crypto.EncryptToString(Password.Text));
Close();
}
else
{
MessageBox.Show("Hostname is not valid");
}
}
}
开发者ID:ReArmedHalo,项目名称:TechnicSolderHelper,代码行数:25,代码来源:ftpInfo.cs
示例11: ValidateSignature
private void ValidateSignature(string signature, string payload)
{
string matchingSignature = null;
string[] signaturePairs = signature.Split('&');
foreach (string signaturePair in signaturePairs)
{
if (signaturePair.IndexOf('|') >= 0)
{
String[] candidatePair = signaturePair.Split('|');
if (Service.PublicKey.Equals(candidatePair[0]))
{
matchingSignature = candidatePair[1];
break;
}
}
}
Crypto crypto = new Crypto();
string computedSignature = crypto.HmacHash(Service.PrivateKey, payload).ToLower();
if (!crypto.SecureCompare(computedSignature, matchingSignature))
{
throw new InvalidSignatureException();
}
}
开发者ID:khorvat,项目名称:braintree_dotnet,代码行数:25,代码来源:WebhookNotificationGateway.cs
示例12: Register
public ActionResult Register(Register register)
{
if (ModelState.IsValid)
{
try
{
ConnectUpdate udb = new ConnectUpdate();
hackathonunitecEntities db = udb.getDB();
user User = new user();
User.email = register.email;
Crypto crypto = new Crypto(register.password);
User.password = crypto.GetHash();
User.firstname = register.firstname;
User.lastname = register.lastname;
User.active = true;
user_role User_Role = new user_role();
User_Role.roleid = 2;
User_Role.active = true;
User.user_role.Add(User_Role);
db.user.Add(User);
db.SaveChanges();
return View("Thanks");
}
catch (Exception ex)
{
Console.Write(ex.ToString());
return View();
}
}
else
{
return View();
}
}
开发者ID:camilorivera,项目名称:gamenhack,代码行数:35,代码来源:HomeController.cs
示例13: FunkyPasswords
public void FunkyPasswords() {
Crypto c = new Crypto();
{
const string source = "antonida";
string s = c.Encrypt(source);
Assert.AreNotEqual(source, s);
Assert.AreEqual(source, c.Decrypt(s));
}
{
const string source = "привет мир";
string s = c.Encrypt(source);
Assert.AreNotEqual(source, s);
Assert.AreEqual(source, c.Decrypt(s));
}
{
const string source = @">rL`Fpbgr>_1j^?];cK5U>/!fm;&736puCLZeql=b-,-}rOdeR";
string s = c.Encrypt(source);
Assert.AreNotEqual(source, s);
Assert.AreEqual(source, c.Decrypt(s));
}
{
for (int i = 0; i < 1000; i++) {
string source = RandomString(Math.Min(i + 1, 50));
string s = c.Encrypt(source);
Assert.AreNotEqual(source, s);
Assert.AreEqual(source, c.Decrypt(s));
}
}
}
开发者ID:TargetProcess,项目名称:Tp.Integration.Ide.VisualStudio,代码行数:29,代码来源:CryptoTest.cs
示例14: PayloadMatches
private bool PayloadMatches(string signature, string payload)
{
var sha1Hasher = new Sha1Hasher();
string computedSignature = sha1Hasher.HmacHash(service.PrivateKey, payload).ToLower();
var crypto = new Crypto();
return crypto.SecureCompare (computedSignature, signature);
}
开发者ID:Jammyhammy,项目名称:braintree_dotnet,代码行数:7,代码来源:WebhookNotificationGateway.cs
示例15: RegisterNewUser
public static void RegisterNewUser(Register regModel)
{
var cryptedPassword = new Crypto().Encrypt(regModel.Password);
var newUser = new User {Email = regModel.Email, PasswordCrypted = cryptedPassword, UserName = regModel.Name};
Save(newUser);
GalerieManager.CreateRootGallery(newUser);
}
开发者ID:senseicz,项目名称:Galerie-KusVola,代码行数:8,代码来源:UserManager.cs
示例16: GetDecryptedParamArray
private static JArray GetDecryptedParamArray(string encryptedStr)
{
string passPhrase = AES_PASS_PHRASE;
Crypto crypto = new Crypto(passPhrase);
string clearData = crypto.DecryptFromBase64(encryptedStr);
JArray paramArray = (JArray)JsonConvert.DeserializeObject(clearData);
return paramArray;
}
开发者ID:williamyip,项目名称:Yardal,代码行数:8,代码来源:Helper.cs
示例17: ChangePasswdDialog
public ChangePasswdDialog(String uName)
{
userName = uName;
passwdPasses = false;
pwdClient = new DBClient();
pwdCrypto = new Crypto();
InitializeComponent();
}
开发者ID:Team7-SoftEng,项目名称:GateofGabethulu-launcher,代码行数:8,代码来源:ChangePasswdDialog.cs
示例18: registerForm
public registerForm()
{
regClient = new DBClient();
cryptSvc = new Crypto();
newCustomer = new Customer();
newAddress = new BillingAddress();
InitializeComponent();
}
开发者ID:Team7-SoftEng,项目名称:GateofGabethulu-launcher,代码行数:8,代码来源:registerForm.cs
示例19: UseCustomKey
public void UseCustomKey() {
const string S = "WqJCvfqa6JKiSXFm6t9MSAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==";
Crypto c = new Crypto("my secret key");
string s = c.Encrypt("hello world");
Assert.AreNotEqual("hello world", s);
Assert.AreEqual("hello world", c.Decrypt(s));
Assert.AreEqual("hello world", c.Decrypt(S));
}
开发者ID:TargetProcess,项目名称:Tp.Integration.Ide.VisualStudio,代码行数:9,代码来源:CryptoTest.cs
示例20: Twitter
public Twitter()
{
Crypto decode_ = new Crypto();
if(!String.IsNullOrEmpty(Regedit.GetKey_("login_name")))
UserName = decode_.DecryptString(Regedit.GetKey_("login_name"));
if (!String.IsNullOrEmpty(Regedit.GetKey_("login_pass")))
Password = decode_.DecryptString(Regedit.GetKey_("login_pass"));
}
开发者ID:gizmo8985,项目名称:togi,代码行数:9,代码来源:Twitter.cs
注:本文中的Crypto类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论