encryption

FMDB and encryption

依然范特西╮ 提交于 2020-01-13 11:07:02
问题 I'm using FMDB to work with sqlite and I'd prefer to avoid a dependency on SQLCipher. How can I simply leverage the DataProtection capability built into iOS? Is this possible - the only requirement is to protect the data in the event of the phone being stolen. If the phone is unlocked with a PIN, it's fine that the user could access the DB - it's their data. 回答1: Look for the line where you do databaseWithPath: (or initWithPath: ), then add: FMDatabase *db = [FMDatabase databaseWithPath:path]

OpenSSL - Password vs Salt Purpose

℡╲_俬逩灬. 提交于 2020-01-13 08:33:08
问题 When encrypting a file with OpenSSL, it is possible to use -pass pass:mySillyPassword, where mySillyPassword is the password used in encryption. In addition, it is possible to use a salt, where -salt -s (hex string) is used to specify the salt. Why would someone want to use a password instead of the salt or in conjunction with a salt? Also, I understand just using the -salt command will cause OpenSSL to generate a salt. How is this better than a user-defined salt? If OpenSSL randomly

Bouncy Castle's Password Based Encryption With AES in CBC mode

谁说胖子不能爱 提交于 2020-01-13 05:51:06
问题 I've recently came across a piece of code that uses BouncyCastle's PBE with AES in CBC mode ("PBEWithSHA1And256BitAES-CBC-BC"). public static final String ALGORITHM = "PBEWithSHA1And256BitAES-CBC-BC"; public static byte[] encrypt(final byte[] key, final byte[] salt, final byte[] plainText) throws CryptoException { try { // Create the encryption key final SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(ALGORITHM, "BC"); final PBEKeySpec keySpec = new PBEKeySpec(new String(key)

Decrypting file in C++, which was encrypted with openssl -aes-128-cbc

☆樱花仙子☆ 提交于 2020-01-13 05:38:28
问题 I'm trying to decrypt a file in C++. This file is encrypted with the following command: openssl enc -nosalt -aes-128-cbc -pass pass:test -in "test.txt" -out "test_enc.txt" -p The console shows the key=098F6BCD4621D373CADE4E832627B4F6 and iv=0A9172716AE6428409885B8B829CCB05 . In C++ I have included the #include openssl/aes.h line and try to decrypt with the following code: const char *indata = string.toAscii().constData(); unsigned char outdata[strlen(indata)]; unsigned char ckey[] =

java.security AES encryption key length

折月煮酒 提交于 2020-01-13 05:07:25
问题 When the key length is 128 bits,everything works. But I got the following exception when I use a key of length 192 or 256 bits. java.security.InvalidKeyException: Illegal key size or default parameters at javax.crypto.Cipher.a(DashoA13*..) at javax.crypto.Cipher.a(DashoA13*..) at javax.crypto.Cipher.a(DashoA13*..) at javax.crypto.Cipher.init(DashoA13*..) at javax.crypto.Cipher.init(DashoA13*..) I found this Java Security: Illegal key size or default parameters?. But after I download the jar

Using streams to decrypt and unzip to limit memory usage?

丶灬走出姿态 提交于 2020-01-13 04:54:25
问题 I have a very large zip file, 2.5gb, which is encrypted. I can't decrypt the entire file into memory and unzip there for production. So I'm trying to use streams to limit the amount of memory used. I've hooked up the following to do it (error handling and stream closing left out for clarity): SecretKeySpec keySpec = new SecretKeySpec(myKey "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); FileInputStream fis = new FileInputStream(new File(pathToEncryptedFile));

Invalid length for a Base-64 char array while decryption

烂漫一生 提交于 2020-01-13 03:15:46
问题 I get the following exception in some cases through (decryption) , and i can't recognize exactly the reason : Invalid length for a Base-64 char array My Code : public static string encodeSTROnUrl(string thisEncode) { if (null == thisEncode) return string.Empty; return HttpUtility.UrlEncode(Encrypt(thisEncode)); } // string thisDecode = "3Dn%2bsJJPXprU4%3d"; //this is the value which cause the exception. public static string decodeSTROnUrl(string thisDecode) { return Decrypt(HttpUtility

Invalid length for a Base-64 char array while decryption

我只是一个虾纸丫 提交于 2020-01-13 03:14:16
问题 I get the following exception in some cases through (decryption) , and i can't recognize exactly the reason : Invalid length for a Base-64 char array My Code : public static string encodeSTROnUrl(string thisEncode) { if (null == thisEncode) return string.Empty; return HttpUtility.UrlEncode(Encrypt(thisEncode)); } // string thisDecode = "3Dn%2bsJJPXprU4%3d"; //this is the value which cause the exception. public static string decodeSTROnUrl(string thisDecode) { return Decrypt(HttpUtility

Making AES decryption fail if invalid password

别等时光非礼了梦想. 提交于 2020-01-13 03:13:07
问题 I've written my own encryption method using AES in a project I've been working on lately using PyCrypto. I use a hash to generate a 32-byte password and feed that to AES-256bit encryption using CBC. The file input is padding using PKCS#7 padding to conform to be divisible by 16. I can encrypt and decrypt the file without incident and the input file originally encrypted along with the output file have the same SHA-256 hash. The only problem I'm finding is that if I supply the wrong passphrase,

Php file encryption methods. Does something simple exist?

亡梦爱人 提交于 2020-01-12 19:07:06
问题 It's seems that there isn't any pleasant way to encrypt a file in php. The built in methods of php, mcrypt, aren't very portable as most servers don't support them. Command line encryption tools are like ugly hacks. There's encryption for strings which is nice, but if we want to encrypt a file it doesn't help very much especially for someone else to unencrypt it. Other encryption tools require public keys, key rings, private keys, blood sample... These seem much too complicated for just