我绝不是一名加密专家,我一直在阅读围绕Stack Overflow和维基百科的一些问题,但在定义IV及其用法方面,没有什么是真正"明确的".
我发现的要点:
我确信还有很多其他要点,有人能想到我错过的任何其他特征吗?
我正在使用asp.net mvc 2.0,我想知道将信息放入cookie有多安全?
就像我在我的cookie中放入一个加密的表单身份验证票据,这样我可以将那些可能敏感的信息放在那里吗?
string encryptedTicket = FormsAuthentication.Encrypt(authTicket)
HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
Run Code Online (Sandbox Code Playgroud)
就像我没有存储密码或类似的东西,但我想存储UserId,因为目前每次用户向我的网站发出请求时,我必须进行查询并获取用户Userid,因为我的数据库中的每个表都需要你使用userId获取正确的行.
所以这些开始快速加起来所以我宁愿这样,如果用户被认证一次,那就是它,直到他们需要再次重新认证.如果我将存储此userId,我可以将如此多的请求保存到数据库中.
然而,我并不希望它以明文形式浮动,因为潜在的人可能会使用它来尝试从数据库中获取一行,而实际上它们应该不存在.
显示身份验证使用的加密有多好?
这与安全无关.它也不会让它难以打破.我正在寻找一种简单的算法来改变一个字符串(一个url),它的方式与原来的不一样.该加密会用JavaScript来完成.然后我想将加密的字符串提供给PHP函数以将其更改回原始字符串.两端都可以共享一个密钥,或者转换可以是无钥匙并依赖于逻辑.
理想的解决方案
编辑:在shamittomar的回答之后添加了最后一个要求.
我正在寻找一个JS加密库(类似于OpenSSL的libcrypto),它有助于在浏览器中对数据进行数字签名.
我想使用私钥(RSA,PKI证书或类似代码)在客户端签署表单表单数据.
例
signature=RSA_encrypt(A_private_key, hash(data))表单数据和签名被发送到服务器并存储
另一位用户(B)可以通过比较检查签名的有效性hash(data)与RSA_decrypt(A_public_key, signature)如果有人改变表单数据的签名将不再有效.
编辑
https://developer.mozilla.org/en/javascript_crypto
http://www.hanewin.net/encrypt
http://tomas.styblo.name/cryptoapplet/
VIA APPLETS
使用用户证书以Web表单签署数据的最佳方式
!=> http://www.nakov.com/research/documents-signing/digital-document-signing-in-java-based-web-applications/
http://www.nakov.com/research/documents-signing/
http://www.developer.com/java/other/article.php/10936_3587361_1
http://www.developer.com/java/web/article.php/3083161
http://blogs.nologin.es/rickyepoderi/的index.php?/archives/12-Signature-Applet.html
相关
http://ccff02.minfin.fgov.be/CCFF_Authentication/views/login/signature/signatureHelp.html
http://msdn.microsoft.com/en-us/library/cc778518%28VS.85%29.aspx
我正在使用此方法加密视频文件:
public static void encryptToBinaryFile(String password, byte[] bytes, File file) throws EncrypterException {
try {
final byte[] rawKey = getRawKey(password.getBytes());
final FileOutputStream ostream = new FileOutputStream(file, false);
ostream.write(encrypt(rawKey, bytes));
ostream.flush();
ostream.close();
} catch (IOException e) {
throw new EncrypterException(e);
}
}
private static byte[] encrypt(byte[] raw, byte[] clear) throws EncrypterException {
try {
final SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
final Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
return cipher.doFinal(clear);
} catch (Exception e) {
throw new EncrypterException(e);
}
}
Run Code Online (Sandbox Code Playgroud)
但它给出了一个错误Outofmemoryerror说拒绝分配301023321元素. …
我正在设计一个如下所示的身份验证系统:
WHERE `Password` = SHA1(CONCAT('$hashedPassword',`Salt`)) AND [..]
Run Code Online (Sandbox Code Playgroud)
目前我的盐是64字节.这足以使词典攻击变得不可行吗?
我确定sha1已知漏洞,但它是我可以在数据库层使用的我的MySQL(5.1)版本上唯一可用的功能,而不是通过应用程序和数据库层之间的连接选择普通的盐.
我真的很挣扎,我需要在C#中使用BouncyCastle加密和解密字符串.我确实试过自己做这件事.我确实创建了自己的密钥(私有和公共密钥).
请记住,我刚从大学毕业.
我必须在我的服务器上解密一个帧.加密帧来自客户端设备通过套接字上的GPRS.加密与做TripleDes的和给定的key.I使用相同的算法和服务器端密钥.Frame是Hex和Ascii String的组合.现在问题是:当我用零填充我的字节数组时,我得到以下异常.
javax.crypto.BadPaddingException: Given final block not properly padded
Run Code Online (Sandbox Code Playgroud)
以下是我的代码:
byte[] key = new byte[]{31, 30, 31, 36, 32, 11, 11, 11, 22, 26,
30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30};
myKeySpec = new DESedeKeySpec(key);
mySecretKeyFactory = SecretKeyFactory.getInstance("TripleDES");
de = mySecretKeyFactory.generateSecret(myKeySpec);
Cipher c = Cipher.getInstance("TripleDES");
c.init(Cipher.DECRYPT_MODE, key);
int l = completeHexStr.length();
if (l%8==1){
completeHexStr = completeHexStr + "0000000";
}else if (l%8==7){
completeHexStr = completeHexStr + "0";
} …Run Code Online (Sandbox Code Playgroud) 我使用下面的代码连接到加密网络.但是,如果网络不安全并且我将密钥留空("")则会失败.有谁知道如何解决这个问题?此外,是否可以使用ssid/bssid检测网络是否打开?或者我必须使用过滤器进行扫描?
public void connectToSSID(final String ssid, final String key) {
Log.i("wifimaster", "connection to "+ssid);
WifiConfiguration wc = new WifiConfiguration();
wc.SSID = "\""+ssid+"\""; //IMPORTANT! This should be in Quotes!!
wc.priority = 40;
wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
wc.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
wc.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
wc.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
wc.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED);
wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);
wc.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP);
wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
wc.preSharedKey = "\""+key+"\"";
wc.wepKeys[0] = "\""+key+"\""; //This is the WEP Password
wc.wepTxKeyIndex = 0;
wc.preSharedKey = "\""+key+"\"";
int res = wifiManager.addNetwork(wc);
Log.d("WifiPreference", "add Network returned " + res );
boolean es = wifiManager.saveConfiguration();
Log.d("WifiPreference", "saveConfiguration …Run Code Online (Sandbox Code Playgroud) 由于Mcrypt已被弃用,我想在我的代码中使用OpenSSL,因为我们已经在我们的服务器中使用了PHP 7.0.17并且没有告诉他们何时升级它.
某些第三方API(可能在PHP 5.x上托管并使用mcrypt)正在使用加密数据.他们提供了用于加密/解密字符串的方法.
他们是这样的
$secret = 'a0a7e7997b6d5fcd55f4b5c32611b87c' ;
public function encrypt128($str)
{
$block = mcrypt_get_block_size("rijndael_128", "ecb");
$pad = $block - (strlen($str) % $block);
$str .= str_repeat(chr($pad), $pad);
return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $secret, $str, MCRYPT_MODE_ECB));
}
public function decrypt128($str)
{
$str = base64_decode($str);
$str = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $secret, $str, MCRYPT_MODE_ECB);
$len = strlen($str);
$pad = ord($str[$len - 1]);
return substr($str, 0, strlen($str) - $pad);
}
Run Code Online (Sandbox Code Playgroud)
small1如果加密,使用这些方法字符串v7IXp5vVaFVXXlt/MN8BVw==
我们希望openssl_encrypt在我们这边使用,如果我们用OpenSSL加密相同的字符串,它必须给出与Mcrypt相同的结果.我研究过使用rijndael-128模式的mcrypt ecb应该与OpenSSL兼容aes-128-ecb. …