Tag: sha1

Telerik Sitefinity密码哈希function

我有一个表格,其中包含Telerik Sitefinity系统的登录凭据。 我想使用相同的登录凭据,但使用不具有Sitefinity库的其他应用程序。 我正在努力使用密码编码,密码编码设置为Hash(默认为SHA1算法)。 我尝试使用以下代码对密码进行编码,但它与Sitefinity生成的内容不匹配。 public string EncodePassword(string pass, string salt) { byte[] bytes = Encoding.Unicode.GetBytes(pass); byte[] src = Convert.FromBase64String(salt); byte[] dst = new byte[src.Length + bytes.Length]; Buffer.BlockCopy(src, 0, dst, 0, src.Length); Buffer.BlockCopy(bytes, 0, dst, src.Length, bytes.Length); HashAlgorithm algorithm = HashAlgorithm.Create(“SHA1”); byte[] inArray = algorithm.ComputeHash(dst); return Convert.ToBase64String(inArray); } 例: 密码:password111 盐:94EBE09530D9F5FAE3D002A4BF262D2F(保存在SF用户表中) 上面的函数哈希:8IjcFO4ad8BdkD40NJcgD0iGloU = SF生成的表中的哈希值:A24GuU8OasJ2bicvT / […]

如何在PHP中复制此C#散列? (toByteArray(),ComputeHash())

我试图在PHP复制以下代码,它是我必须与之接口的API的示例代码(API和示例代码在C# ,我的应用程序在PHP 5.3 )。 我不是C#开发人员,所以我很难做到这一点。 // C# Code I am trying to replicate in PHP var apiTokenId = 1887; var apiToken = “E1024763-1234-5678-91E0-T32E4E7EB316”; // Used to authenticate our request by the API (which is in C#) var stringToSign = string.Empty; stringToSign += “POST”+”UserAgent”+”http://api.com/post”; // Here is the issue, How can I do the following 3 […]

HMC SHA1哈希 – C#产生与Ruby不同的哈希输出

我正在努力为我正在使用的第三方服务快速获取一个bug .Net客户端库。 原始库(可以工作)是用Ruby编写的,但它们等效的DotNet库为Ruby库产生了不同的哈希输出。 Ruby加密代码如下: def self.encrypt_string(input_string) raise Recurly::ConfigurationError.new(“Recurly gem not configured”) unless Recurly.private_key.present? digest_key = ::Digest::SHA1.digest(Recurly.private_key) sha1_hash = ::OpenSSL::Digest::Digest.new(“sha1”) ::OpenSSL::HMAC.hexdigest(sha1_hash, digest_key, input_string.to_s) end (假设)等效的C#代码是: private static string ComputePrivateHash(string dataToProtect) { if(String.IsNullOrEmpty(Configuration.RecurlySection.Current.PrivateKey)) throw new RecurlyException(“A Private Key must be configured to use the Recurly Transparent Post API.”); byte[] salt_binary = SHA1.Create().ComputeHash(Encoding.ASCII.GetBytes(dataToProtect)); string salt_hex = BitConverter.ToString(salt_binary).Replace(“-“, “”).ToLower(); […]

在没有第三方库的情况下设置Twitter OAuth

继续获取Twitter公共时间线,json + C#,没有第三方库 我还是C#和oAuth的新手,所以如果我什么都不懂,请耐心等待 我创建了一个名为oAuthClass的C#类,这些是我目前拥有的变量: static class oAuthClass { public static void run() { int oauth_timestamp = GetTimestamp(DateTime.Now); string oauth_nonce = PseudoRandomStringUsingGUID(); string oauth_consumer_key = “consumer key here”; string oauth_signature_method = “HMAC-SHA1”; string oauth_version = “1.0”; } } 我已经阅读了OAuth签名,我现在选择使用HMAC-SHA1,我不知道如何生成签名,在阅读和查看HTTP-Encodings和Base-Strings等内容后,我也非常困惑还有什么(我根本不知道它们的意思),但我的想法是创建一个“Http-encoded”的URL,就像空格 – >“%20”一样? 总结: – 什么是基本字符串? – 我在空间 – >%20例子吗? -HMAC-SHA1涉及消息和密钥,是消费者秘密的消息吗? 消费者关键是关键吗? – 如何通过使用HMAC-SHA1算法创建签名 – 如果我设法创建签名,我如何将这些值传递给Twitter? 我可以用 […]

在可移植类库中生成SHA1哈希

我正在尝试构建一个可移植的类库,为其他类/应用程序生成OAuth URL。 这个使用OAuth的类库必须是一个可移植的类库,因此它可以与我正在构建的DropBox API的不同版本一起使用。 此类的一部分需要生成SHA1哈希以生成oauth_signature。 我知道可移植类库不支持System.Security.Cryptography,所以无论如何这个类可以生成没有该类的SHA1哈希?

WS-Security中PasswordDigest的工作算法

我遇到了WS-Security的问题,并创建了一个正确的随机数和密码摘要。 我成功使用SoapUI将数据发送到Oracle系统。 所以我能够拦截SoapUI的调用(将代理更改为127.0.0.1端口8888以使用Fiddler失败,因为它是通过SSL) – 拦截非常重要,因为这些值只能使用一次。 然后我可以获取nonce,创建时间戳和密码摘要将它们放入我的代码中(我只有30秒的时间来执行此操作,因为值不会持续!)并且我获得了成功。 所以我知道它不是别的 – 只是密码摘要。 我使用的值如下: Nonce: UIYifr1SPoNlrmmKGSVOug== Created Timestamp: 2009-12-03T16:14:49Z Password: test8 Required Password Digest: yf2yatQzoaNaC8BflCMatVch/B8= 我知道创建摘要的算法是: Password_Digest = Base64 ( SHA-1 ( nonce + created + password ) ) 使用以下代码(来自Rick Strahl的post ) protected string GetSHA1String(string phrase) { SHA1CryptoServiceProvider sha1Hasher = new SHA1CryptoServiceProvider(); byte[] hashedDataBytes = sha1Hasher.ComputeHash(Encoding.UTF8.GetBytes(phrase)); return Convert.ToBase64String(hashedDataBytes); } […]

我如何在文件上执行SHA1哈希?

如果我有一个文件,我想监视任何更改(除了查看文件日期戳等)。 我怎么能对其内容执行SHA1哈希? 我认为这就是GIT的作用,所以我只想学习如何做到这一点

Python hmac和C#hmac

我们有一个python Web服务。 它需要一个哈希作为参数。 python中的哈希是以这种方式生成的。 hashed_data = hmac.new(“ant”, “bat”, hashlib.sha1) print hashed_data.hexdigest() 现在,这就是我如何从C#生成哈希。 ASCIIEncoding encoder = new ASCIIEncoding(); Byte[] code = encoder.GetBytes(“ant”); HMACSHA1 hmSha1 = new HMACSHA1(code); Byte[] hashMe = encoder.GetBytes(“bat”); Byte[] hmBytes = hmSha1.ComputeHash(hashMe); Console.WriteLine(Convert.ToBase64String(hmBytes)); 但是,我出来的结果不同了。 我应该改变散列的顺序吗? 谢谢, 乔恩

SHA1纯文本? C#.NET

我正在使用C#并为字符串计算SHA1。 我的问题是,这总是会产生纯文本0-1和AZ吗? 或者它也会产生具有特殊字符的东西? 我的意思是ComputeHash函数在这里会返回纯文本吗? SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider(); string receivedValue = BitConverter.ToString(sha1.ComputeHash(to_be_hash)).Replace(“-“, “”); 不确定,但我认为它应该只有在转换为Base 64时才会生成特殊字符。

如何在C#中使用SHA1或MD5?(哪一个在身份validation和安全性方面更好)

在C#中我们如何自动使用SHA1? SHA1是否优于MD5?(我们使用哈希来获取用户名和密码,并需要速度进行身份validation)