如何加密mnesia数据库以及加密mnesia数据库最安全的方法是什么.
在erlang中是否有任何内置方法可以高安全性地加密和解密数据?
我正在尝试使用Crypto ++加密文本.上次使用AES CTR时效果很好,但现在使用CBC或GCM时,我可以使用的最大密钥长度是32位??
处理加密的代码:
string xAESPlain, xAESCipher;
AutoSeededRandomPool xRng;
byte xAESKey[128]; // Doesnt Work has to be 32 or 16
byte xAESIv[128];
xRng.GenerateBlock(xAESKey, sizeof(xAESKey));
xRng.GenerateBlock(xAESIv, sizeof(xAESIv));
CBC_Mode< AES >::Encryption E;
E.SetKeyWithIV(xAESKey, sizeof(xAESKey), xAESIv);
StringSource ss(xAESPlain, true,
new StreamTransformationFilter(E,
new StringSink(xAESCipher)
)
);
Run Code Online (Sandbox Code Playgroud)
运行此Crypto ++时会抛出Exception:
terminate called after throwing an instance of 'CryptoPP::InvalidKeyLength'
what(): AES/CBC: 128 is not a valid key length
Run Code Online (Sandbox Code Playgroud)
请注意,使用Wiki中提供的example.zip(并将密钥长度更改为256或128)时会发生相同的情况
有什么想法Exception被抛出?
首先,我是Android编程的新手,虽然我不是编程本身的新手.实际上,我的目的是将加密密钥保存到Android密钥库中.GOOGLE本身似乎非常缺乏此类信息.由于关于该主题的方法不多,我假设它不是相当标准的知识.那么有人可以给我一个示例代码
所以本质上是密钥库的所有基本功能的代码.提前感谢您的协助.
现在,我已经有了一个密钥对.
我想在我的Swift中导入这个密钥对,并使用此密钥对进行加密
某事或解密我从restclint得到的东西
我看到很多论文都在说如何一般的密钥对,但我已经拥有它.
什么是kSecAttrApplicationTag呢?
请帮助我
var dataPtr:Unmanaged<AnyObject>?
let query: [String:AnyObject] = [
kSecClass: kSecClassKey,
kSecAttrApplicationTag: "com.example.site.public",
kSecReturnData: kCFBooleanTrue
]
let qResult = SecItemCopyMatching(query, &dataPtr)
// error handling with `qResult` ...
let publicKeyData = dataPtr!.takeRetainedValue() as NSData
// convert to Base64 string
let base64PublicKey = publicKeyData.base64EncodedStringWithOptions(nil)
Run Code Online (Sandbox Code Playgroud) 好的,最初的任务是在2个能够共享用户cookie的"友好"网站中跟踪用户(比方说,我有example.com,我的朋友有mysite.com,而且他有一个域simple.example. com所以他可以在.example.com上设置cookie.
要跟踪我们想要设置唯一cookie的用户活动,此cookie应该是唯一的并且长度为32个字节(ascii).从这个角度来看非常简单,可以这样实现:
md5(microtime)
Run Code Online (Sandbox Code Playgroud)
就是这样,但现在我们有了新的约束:
我们应该能够告诉谁确切地设置了cookie:exmaple.com引擎或mysite.com引擎
仍然需要32个字节的长度
我们应该能够加密时间戳(发布cookie时)
结果cookie值的第一个和最后一个字符应该不同,所以我们可以根据cookie进行A/B测试(所以我们总是可以说,如果cookie的最后一个字符是"> K",则显示此用户"功能A")
鉴于结果字符串的长度应始终为32个或更少,并且数据应加密和解密(当然不是用户),并且字符串对于用户应该是唯一的,这使得任务非常复杂.
我的想法和问题:
我们应该使用对称密钥加密(解决约束 1和3),但是在这种情况下我们如何确保结果字符串不超过32个字符(约束 2)?
考虑到我们需要加密的数据量是:时间戳和微秒(14字节),站点发布者标志(1字节)=总共15字节,还有其他解决方案吗?
我的第一个想法是将数据打包成二进制字符串而不是base64编码.结果将是8-chars长base64编码的字符串:
def encode():
base64( pack('Lv', timestamp, microseconds) )
Run Code Online (Sandbox Code Playgroud)
在开头和结尾添加site-issuer标志和字符:
def getCookie():
rand('a'...'Z') + encode() + issuerFlagChar() + rand('a'...'Z')
Run Code Online (Sandbox Code Playgroud)
因此,结果是11个字符长,我们很容易满足约束2.
但问题是:这个算法肯定不安全,我不确定数百万网站用户的结果字符串是否是唯一的.
我想知道我是否可以为此目的使用DES或AES,但我不确定结果字符串是否总是满足约束2(结果字符串不应超过32个ascii字符).
是否存在对称密钥算法,以确保"如果使用M字节密钥加密N个字节,那么结果数据长度为Math.Ceil(N*2 + 1/M)字节"?因此产生的长度是可预测的?
这是一个很棒的php类,可以在php中进行安全的双向加密.我在一个项目中使用它,需要对它的方法进行数千次调用,
我想将它转换为一个完整的静态类及其所有方法,以提高性能并避免在每次新方法调用时使用新实例
/**
* A class to handle secure encryption and decryption of arbitrary data
*
* Note that this is not just straight encryption. It also has a few other
* features in it to make the encrypted data far more secure. Note that any
* other implementations used to decrypt data will have to do the same exact
* operations.
*
* Security Benefits:
*
* - Uses Key stretching
* - Hides the Initialization Vector
* - …Run Code Online (Sandbox Code Playgroud) 我得到了一个用rc4密钥加密的文件。
我获得了该密钥,并希望使用python脚本对其进行解密。
我怎样才能做到这一点?
我需要隐藏最终用户输出中的某些原始值(主要是主键,每个请求可能约为100个),这样就无法轻易地探测或迭代数据库.加密速度比值的实际不可穿透性更重要.
我目前正在使用PBEWithMD5AndDES以下包装器 - 这是否过度杀伤?我是使用Java作为Web后端的新手.
public class SecurityHelper {
private static final String DEFAULT_KEY = "some-key-here";
private SecretKey secretKey;
private PBEParameterSpec parameterSpec;
private Cipher cipher;
public SecurityHelper() {
try {
char[] moduleKeyChars = DEFAULT_KEY.toCharArray();
KeySpec keySpec = new PBEKeySpec(moduleKeyChars);
secretKey = SecretKeyFactory.getInstance(
"PBEWithMD5AndDES").generateSecret(keySpec);
parameterSpec = new PBEParameterSpec(new byte[8], 1);
cipher = Cipher.getInstance("PBEWithMD5AndDES");
} catch (Exception e) {
e.printStackTrace();
}
}
public String encrypt(String secret) {
String encrypted = null;
try {
cipher.init(Cipher.ENCRYPT_MODE, secretKey, parameterSpec);
byte[] stateBytes = cipher.doFinal(secret.getBytes("UTF-8"));
encrypted …Run Code Online (Sandbox Code Playgroud) 我按下提交按钮时尝试加密密码.
我不明白为什么密码输入的值没有改变,ecryption正确完成.
<script>
function cript(){
var pass = CryptoJS.SHA1("<?php echo $_POST["password"]; ?>");
var passString = pass.toString();
console.log(passString);
document.getElementById('inputPassword').value = passString;
}
</script>
Run Code Online (Sandbox Code Playgroud)
并在HTML表单上:
<input type="submit" class="btn btn-primary" value="Proceed" onclick="cript()">
Run Code Online (Sandbox Code Playgroud)
谁能告诉我解决方案?
我有一个启用了客户端节点加密的Cassandra集群.我正在尝试将此群集添加到OpsCenter 5.1.0的实例,但它无法连接到群集.日志文件似乎抱怨无法验证SSL证书:
`
INFO: Starting factory opscenterd.ThriftService.NoReconnectCassandraClientFactory instance at 0x7f2ce05c8638>
2015-06-10 15:09:46+0000 [] WARN: Unable to verify ssl certificate.
2015-06-10 15:09:46+0000 [] Unhandled Error
Traceback (most recent call last):
File "/opt/opscenter-5.1.0/lib/py-debian/2.7/amd64/twisted/python/log.py", line 84, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
File "/opt/opscenter-5.1.0/lib/py-debian/2.7/amd64/twisted/python/log.py", line 69, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "/opt/opscenter-5.1.0/lib/py-debian/2.7/amd64/twisted/python/context.py", line 59, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/opt/opscenter-5.1.0/lib/py-debian/2.7/amd64/twisted/python/context.py", line 37, in callWithContext
return func(*args,**kw)
--- exception caught here ---
File "/opt/opscenter-5.1.0/lib/py-debian/2.7/amd64/twisted/internet/epollreactor.py", line …