我正在使用CodeIgniter构建一个快速站点,目前我正在使用CI'加密'库.通过这里阅读听起来像我只是快速:
$this->encrypt->encode($secret_data);
Run Code Online (Sandbox Code Playgroud)
并在您想要使用它时执行此操作:
$this->encrypt->decode($encripted_string);
Run Code Online (Sandbox Code Playgroud)
然后CI和Mcrypt的魔力完成其余的工作.
好吧,我不确定在不知道后台发生了什么的情况下我可以睡觉.所以我有两个问题......
这是怎么回事?或者是否有一个很好的资源向我解释这是如何工作的,我可以阅读它?
这通常被认为是加密数据的安全方式吗?如果不是我应该在哪里看.
php encryption cryptography codeigniter encryption-symmetric
当我将这些东西添加到我的mysql数据库时,我想加密我的php文件中的一些数据.
我就是这样做的.
我创建一个静态键,如:
$key = md5("uJHyFVSG");
Run Code Online (Sandbox Code Playgroud)
然后我有两个函数,名为encrypt()和decrypt(),他们这样做:
function encrypt($string, $key){
$string = rtrim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $string, MCRYPT_MODE_ECB)));
return $string;
}
function decrypt($string, $key){
$string = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($string), MCRYPT_MODE_ECB));
return $string;
}
Run Code Online (Sandbox Code Playgroud)
我不确定这是否是最佳做法,但是我如何生成除md5以外的密钥?
我正在C#为我的公司创建一个新的应用程序.
我们的SQL数据库存储的密码使用用户MD5加密这是通过我们使用其他应用程序创建MS Access在VBA.
我们使用本网站的代码 - http://www.di-mgt.com.au/crypto.html#MD5作为我们的VBA应用程序.
我在那个网站上看到我应该可以在另一个平台上解密密码:http://www.di-mgt.com.au/cryptoCrossPlatform.html
但我不知道我怎么能这样做C#.
我还查看了一些代码CodeProject- 但是解密会将不同的结果拉回到已存储在我们数据库中的内容.http://www.codeproject.com/Articles/38951/How-To-Hash-Data-Using-MD-and-SHA
如何在我的新C#应用程序中验证此登录?
编辑: 这是我现在正在使用的哈希.
/// <summary>
/// take any string and encrypt it using MD5 then
/// return the encrypted data
/// </summary>
/// <param name="data">input text you will enterd to encrypt it</param>
/// <returns>return the encrypted text as hexadecimal string</returns>
private string GetMD5HashData(string data)
{
//create new instance of …Run Code Online (Sandbox Code Playgroud) 我试图使密钥库帮助我生成用于AES加密的密钥,并使用它来加密我输入的纯文本。所以这是我的代码。我在另一个活动的onCreate()方法中仅调用一次createKey()方法,然后使用相同的keyAlias和相同的纯文本多次调用printCipherText()方法。奇怪的是:每次我调用printCipherText()方法时,都会得到不同的结果。我使用相同的密钥别名和相同的明文,但是为什么每次都得到不同的密文?
public class KeyCreatorClass {
KeyStore keyStore;
KeyGenerator keyGenerator;
Cipher cipher;
public void createKey(String keyAlias) { //I call this method only once in the onCreate() method of another activity, with keyAlias "A"
try {
keyStore = KeyStore.getInstance("AndroidKeyStore");
keyGenerator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore");
cipher = Cipher.getInstance("AES/CBC/PKCS7Padding");
keyStore.load(null);
keyGenerator.init(
new KeyGenParameterSpec.Builder(keyAlias, KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT)
.setBlockModes(KeyProperties.BLOCK_MODE_CBC)
.setUserAuthenticationRequired(false)
.setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_PKCS7)
.setRandomizedEncryptionRequired(false)
.build());
keyGenerator.generateKey();
} catch (Exception e) {
e.printStackTrace();
}
}
public String printCipherText(String keyAlias, String plainText){ //I call this method many times with the same …Run Code Online (Sandbox Code Playgroud) 我想加密我的web.config的connectionstring部分.我尝试按照以下步骤执行此操作:
它是我的错误" 无法为请求的配置对象创建配置文件.失败 "
我做了一些谷歌但我无法理解为什么我面对这个.我试图更改网站文件夹的权限?
我需要在IIS中设置网站吗?请帮我解决这个问题.
提前致谢.
下面是我刚才在互联网上找到的加密/解密类的简化版本.
我一直用它来以加密格式将密码存储在配置文件中,这样就不能通过窥探来读取它.然后可以解密inapp以访问网络资源.
我正在使用它来阻止任何人以任何方式读取纯文本密码,例如配置文件,将其作为命令行变量传递,该变量必须在计划任务中等.
这是一个控制台应用程序,其中一个命令行参数允许用户获取他们提供的字符串密码的加密版本,没有可公开访问的解密方法.
将类设置为内部足以阻止某人调用Decrypt方法或对加密密码进行反向工程,我猜它会阻止任何人引用它并只是调用解密方法但我可以做任何事情否则加强安全?
我想过将Key和Vector从外部传递给构造函数,但是如果它们仍然在同一个dll中,如果有人可以获得这些字节,那么它是否真的有助于提高安全性?
internal class SimpleAES
{
private byte[] Key = { 1, 2, .. n };
private byte[] Vector = { 1, 2, .. n };
private ICryptoTransform EncryptorTransform, DecryptorTransform;
private System.Text.UTF8Encoding UTFEncoder;
public SimpleAES()
{
RijndaelManaged rm = new RijndaelManaged();
EncryptorTransform = rm.CreateEncryptor(this.Key, this.Vector);
DecryptorTransform = rm.CreateDecryptor(this.Key, this.Vector);
UTFEncoder = new System.Text.UTF8Encoding();
}
public string EncryptToString(string TextValue)
{
return ByteArrToString(Encrypt(TextValue));
}
public byte[] Encrypt(string TextValue)
{
Byte[] bytes = UTFEncoder.GetBytes(TextValue);
MemoryStream memoryStream = new MemoryStream(); …Run Code Online (Sandbox Code Playgroud) 为了使其更适用于其他人,我想知道写代码是多么逼真,它会将消息加密到没有密码就不可能被解密的程度.我认为最好的方法是制作哈希算法并添加随机性.那么业余爱好者编写声音加密有多现实?任何工程师都能破解业余加密算法吗?编辑:几个答案讨论了对计算机内存的攻击,这是我很欣赏的有用信息,但我更感兴趣的是知道该消息是否可以直接解密.我假设cryptoanalyser无法访问计算机混淆消息,因为如果他这样做他无论如何都可以查看我的源代码并找到解密算法.这是我的例子:
public class Keys { // hold the methods and information used to lock, unlock, make the key, get the "keypad" after it has been locked, and a static method to change int[] to long[]
// Fields
private String passphrase;
private long[] key;
private long keynum;
private long[] pad;
Random rands = new Random();
// Constructors
public Keys (String passphrase) // makes a key based of the given passphrase
{
this.passphrase = passphrase;
key = keycipher(this.passphrase.toCharArray());
key = keyfix(key);
keynum …Run Code Online (Sandbox Code Playgroud) 我Security在CakePHP 3.2中使用实用程序进行加密和解密.我打电话的时候
Security::encrypt('string', 'key') //密钥长度为32或更多
在字符串上的方法,它返回带有一些无效字符的加密字符串,如下所示:
8e88c050ff20cb12984bf1af24b11fc7ada198082c67d6b3da7170572d5bcd54plp21ķ;ܝ%N
我想用这个字符串url.但由于存在一些无效字符,因此无法正常工作.
现在我想避免这些角色.有没有办法避免这些角色?
我试图内联我的IV,以便我可以解密我的消息而不知道最初的IV,只是秘密密钥.
我生成了我的钥匙.我使用SecureRandom生成我的IV我对IV字节数组进行了randominze.(我使用iv +消息创建一条消息)最后,我用唯一的IV加密消息.
正如预期的那样,如果我在接收端删除IV,我可以解密该消息.但是,生成的密文始终相同.
我不知道为什么会这样,并且还没有在网上找到解决方案.
下面是我的代码和输出.
谁能帮助我理解为什么会这样?
enter code
String mssg = "Hello hellow hello";
byte[] key = "kljhn1234512345abcde123451234512".getBytes();
SecretKeySpec spec = new SecretKeySpec(key, "AES");
SecureRandom rand = new SecureRandom();
for (int i = 0; i < 5; i++) {
//
//initialzize empty byte array for random IV
byte[] iv = new byte[16];
System.out.println("IV pre rand: " + Arrays.toString(iv));
rand.nextBytes(iv); //RANDOMIZE
System.out.println("IV POST rand: " + Arrays.toString(iv));
//CONCATENTATE IV TO FRONT OF MESSAGE TO ENCRYPT
//CONCATENATE MESSAGE TO END OF …Run Code Online (Sandbox Code Playgroud) encryption ×10
java ×3
php ×3
aes ×2
c# ×2
cryptography ×2
security ×2
android ×1
asp.net ×1
asp.net-mvc ×1
cakephp ×1
codeigniter ×1
hash ×1
ios ×1
mcrypt ×1
md5 ×1
vba ×1
web-config ×1
whatsapp ×1