使用SHA1加密 [英] Encryption using SHA1

查看:152
本文介绍了使用SHA1加密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个大型应用程序,并且当数据在不同大陆的两台计算机之间传输时,我需要加密.我从未从事过加密工作.我想要一个可以在PHP/Ruby/Python中处理而没有任何依赖关系的简单加密.

I am developing a large application and i need encryption when a data is traveling between two machines in different continents. I have never worked on encryption. I want a simple encryption which can be handled in PHP / Ruby / Python without any dependencies.

因此,我决定使用HMAC SHA1.

So i decided to use HMAC SHA1.

$pad=hash_hmac("sha1","The quick brown....","mykey");

这是我在互联网上进行一些研究后发现的.

This is what i found out after some research on the internet.

如果有人不知道密钥,解密它有多难?另外,还有其他替代方法吗?

How hard it is to decrypt it if someone doesn't know the key? Also, any alternatives to this?

更新-感谢所有答复.问题解决了.

UPDATE - thanks for all the responses. Problem solved.

推荐答案

即使知道密钥也无法解密. HMAC SHA1是一种密钥哈希算法,不是加密.

It's impossible to decrypt it, even if you know the key. HMAC SHA1 is a keyed hash algorithm, not encryption.

散列是一种加密的单向函数,无论输入的长度如何,该函数始终会生成相同长度的值(我认为SHA1是128位).哈希的要点是,给定输出值,在计算上找不到要产生该输出的输入值是不可行的.密钥哈希用于防止彩虹表攻击.即使知道密钥,也无法撤消哈希过程.

A hash is a cryptographic one-way function that always generates a value of the same length (I think SHA1 is 128-bits) regardless of the length of the input. The point of a hash is that, given the output value, it's computationally infeasible to find an input value to produce that output. A keyed hash is used to prevent rainbow table attacks. Even if you know the key you can't reverse the hash process.

对于加密,您需要查看AES.

For encryption you want to look at AES.

这篇关于使用SHA1加密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆