我正在设计一个网站,用户可以尽快解决难题.JavaScript用于计算每个拼图,并在拼图完成时通过AJAX将毫秒数发送到服务器.如何确保服务器收到的时间不是由用户伪造的?
我不认为基于会话的真实性令牌(Rails中用于表单的那种)就足够了,因为我需要验证值的来源,而不仅仅是请求的合法性.
有没有办法以加密方式签署请求?我想不出黑客无法复制的任何东西.任何JavaScript,由于其暴露的客户端性质,都会受到篡改吗?我是否必须使用像Flash这样的编译器?(Yikes.)或者有什么方法可以隐藏密钥吗?或者其他我没想过的东西?
更新:为了澄清,我不想惩罚网络连接速度慢的人(网络速度应该被视为不一致),因此时间需要100%客户端(只有当我们知道用户可以看到时,计时器才会启动谜题).此外,涉及金钱,因此不能接受"信任用户"的数量.
这是我运行的例子.它具有相同的Mode,Padding,BlockSize,KeySize.我使用相同的init向量,密钥和数据.
使用RijndaelManaged产生加密值:0x8d,0x81,0x27,0xc6,0x3c,0xe2,0x53,0x2f,0x35,0x78,0x90,0xc2,0x2e,0x3b,0x8a,0x61,0x41,0x47,0xd6,0xd0,0xff ,0x92,0x72,0x3d,0xc6,0x16,0x2b,0xd8,0xb5,0xd9,0x12,0x85
使用AesCryptoServiceProvider生成加密值:0x8d,0x9f,0x6e,0x99,0xe9,0x54,0x8b,0x12,0xa9,0x88,0x1a,0x3d,0x65,0x23,0x9c,0x4e,0x18,0x5a,0x89,0x31,0xf5 ,0x75,0xc5,0x9e,0X0D,0x43,0xe9,0x86,0xd4,0xf3,0x64,0x3a
这是我用来生成这些结果的代码
public partial class AesTest
{
private SymmetricAlgorithm mEncryptionType;
private byte[] mPrivateKey;
private byte[] mInitializationVector;
private byte[] mData;
public AesTest()
{
mPrivateKey = new byte[32]
{
0x22, 0x22, 0x22, 0x22,
0x22, 0x22, 0x22, 0x22,
0x22, 0x22, 0x22, 0x22,
0x22, 0x22, 0x22, 0x22,
0x22, 0x22, 0x22, 0x22,
0x22, 0x22, 0x22, 0x22,
0x22, 0x22, 0x22, 0x22,
0x22, 0x22, 0x22, 0x22
};
mInitializationVector = new byte[16]
{
0x33, 0x33, 0x33, 0x33,
0x33, 0x33, 0x33, 0x33,
0x33, 0x33, 0x33, …Run Code Online (Sandbox Code Playgroud) 有谁知道如何解决这个问题?我尝试了很多东西,但没有一个能奏效.
当我点击更多细节时,我得到了这个:
at sun.security.provider.JavaKeyStore.engineLoad(Unknown Source)
atsun.security.provider.JavaKeyStore$JKS.engineLoad(Unknown Source)
at java.security.KeyStore.load(Unknown Source)
at com.sun.deploy.security.RootCertStore$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.deploy.security.RootCertStore.loadCertStore(Unknown Source)
at com.sun.deploy.security.RootCertStore.load(Unknown Source)
at com.sun.deploy.security.RootCertStore.load(Unknown Source)
at com.sun.deploy.security.ImmutableCertStore.load(Unknown Source)
at com.sun.deploy.security.TrustDecider.isAllPermissionGranted(Unknown Source)
at com.sun.deploy.security.TrustDecider.isAllPermissionGranted(Unknown Source)
at sun.plugin.security.PluginClassLoader.getPermissions(Unknown Source)
at java.security.SecureClassLoader.getProtectionDomain(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at …Run Code Online (Sandbox Code Playgroud) 我正在尝试加密数据库中的一些文本,以便在程序启动期间加载和解密.
我尝试了一些方法,包括第三方库https://github.com/richard-lyman/lithcrypt无济于事.使用以下方法加密/解密8/10项,但似乎在加密/解密中的某些点留下了一些填充残差.现在我的代码是这样的:
package client
import (
"encoding/base64"
"crypto/aes"
"crypto/cipher"
"fmt"
)
var iv = []byte{34, 35, 35, 57, 68, 4, 35, 36, 7, 8, 35, 23, 35, 86, 35, 23}
func encodeBase64(b []byte) string {
return base64.StdEncoding.EncodeToString(b)
}
func decodeBase64(s string) []byte {
data, err := base64.StdEncoding.DecodeString(s)
if err != nil { panic(err) }
return data
}
func Encrypt(key, text string) string {
block, err := aes.NewCipher([]byte(key))
if err != nil { panic(err) }
plaintext := []byte(text)
cfb …Run Code Online (Sandbox Code Playgroud) 在(PHP首选)加密密码的最快,最安全的方法是什么?您选择的哪种方法是可移植的?
换句话说,如果我以后将我的网站迁移到其他服务器,我的密码会继续有效吗?
我被告知现在使用的方法取决于服务器上安装的库的确切版本.
混淆,散列和加密有什么区别?
这是我的理解:
我正在用Python创建一个程序,通过安装程序分发给Windows用户.
该程序需要能够每天下载一个使用用户公钥加密的文件,然后对其进行解密.
所以我需要找到一个Python库,让我生成公共和私有PGP密钥,并解密用公钥加密的文件.
这是pyCrypto会做的事情(文档是模糊的)?还有其他纯Python库吗?如何使用任何语言的独立命令行工具?
到目前为止我所看到的只是GNUPG,但是在Windows上安装它会对注册表产生影响,并且无处不在地抛出dll,然后我不得不担心用户是否已经安装了这个,如何备份他们现有的密钥环等等.我宁愿只需要一个python库或命令行工具,并自己管理密钥.
更新:pyME可能会工作,但它似乎与我必须使用的Python 2.4不兼容.
我想使用.Net Security命名空间中提供的加密算法,但是我试图了解如何生成密钥,例如AES算法需要256位,即16字节密钥,以及一些初始化向量,这也是几个字节.
我可以在Key和IV中使用任何值的组合吗?例如Key和IV中的所有零都有效吗?我知道算法的细节做了很多xors,所以零不会有任何好处,但这些算法是否有任何限制?
或者我是否必须使用某些程序生成密钥并将其永久保存在某处?
我希望在加密后将数据存储在数据库中,安全配置文件数据(如用户名,密码,电话号码等)和密钥将仅供连接字符串中提到的数据库用户使用,并且可供管理员使用.
我有一个gpg .key文件,用作解密.dat.pgp文件的密码.使用以下命令在一台服务器上使用相同的.key文件成功解密加密的.data.pgp文件
cat xxx_gpg.key | /usr/bin/gpg --batch --quiet -o xxx.dat --passphrase-fd O -d xxx.dat.pgp
Run Code Online (Sandbox Code Playgroud)
但是,当我将相同的密钥移动到另一个服务器xxx_gpg.key并运行相同的上述命令时,我得到以下错误 -
gpg: decryption failed: No secret key
Run Code Online (Sandbox Code Playgroud)
编辑:
我发现它gpg --list-secret-keys返回服务器上的一些数据,但是没有为其他服务器返回结果.
我们如何配置密钥
我AES/GCM/NoPadding在Java 8中使用加密,我想知道我的代码是否存在安全漏洞.我的代码似乎有效,因为它加密和解密文本,但一些细节尚不清楚.
我的主要问题是:
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] iv = cipher.getIV(); // ?????
Run Code Online (Sandbox Code Playgroud)
IV是否满足"对于给定的密钥,IV不得重复"的要求.来自RFC 4106?
我也很感激我对相关问题的任何答案/见解(见下文),但第一个问题最让我烦恼.我不知道在哪里可以找到解决此问题的源代码或文档.
这是完整的代码,粗略.如果我在撰写这篇文章时引入了错误,我深表歉意:
class Encryptor {
Key key;
Encryptor(byte[] key) {
if (key.length != 32) throw new IllegalArgumentException();
this.key = new SecretKeySpec(key, "AES");
}
// the output is sent to users
byte[] encrypt(byte[] src) throws Exception {
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] iv = cipher.getIV(); // See question #1
assert iv.length == 12; // See question …Run Code Online (Sandbox Code Playgroud)