encryption

How to implement laravel function Crypt::encrypt() in Objective C?

折月煮酒 提交于 2020-02-02 13:05:09
问题 I need to implement Crypt::ecrypt('123456'); from laravel to Objective C iOS . So first i expanded laravel method for encryption like this to pure php: public function enc($text,$key) { $key = (string)base64_decode($key); $iv = random_bytes(16); $value = \openssl_encrypt(serialize($text), 'AES-256-CBC', $key, 0, $iv); $bIv = base64_encode($iv); $mac = hash_hmac('sha256', $bIv.$value, $key); $c_arr = ['iv'=>$bIv,'value'=>$value,'mac'=>$mac]; $json = json_encode($c_arr); $crypted = base64

How to implement laravel function Crypt::encrypt() in Objective C?

空扰寡人 提交于 2020-02-02 13:05:05
问题 I need to implement Crypt::ecrypt('123456'); from laravel to Objective C iOS . So first i expanded laravel method for encryption like this to pure php: public function enc($text,$key) { $key = (string)base64_decode($key); $iv = random_bytes(16); $value = \openssl_encrypt(serialize($text), 'AES-256-CBC', $key, 0, $iv); $bIv = base64_encode($iv); $mac = hash_hmac('sha256', $bIv.$value, $key); $c_arr = ['iv'=>$bIv,'value'=>$value,'mac'=>$mac]; $json = json_encode($c_arr); $crypted = base64

C# equivalent to this ColdFusion Decrypt function

天大地大妈咪最大 提交于 2020-02-02 10:18:48
问题 I have a function in ColdFusion that encrypts and decrypts passwords. I need someone to look at the function and point me to or write me a c# equivalent. It is needed for a project asap so I can throw you some cash through paypal if you can help. CF function: Decrypt("CLbtkjNkcofJ5D8s4Ri7nA==", "EajmplPP8DHg6Tqq8BVRMw==", "AES", "Base64") This is the real function, with real data from a test side, that needs to be converted. Any help would be awesome .. and profitable. Thanks, Donnie 回答1:

When encrypting data that is not an even multiple of the block size do I have to send a complete last block?

随声附和 提交于 2020-02-02 07:15:12
问题 If I am using a block cipher such as AES which has a block size of 128 bits, what do I do if my data is not an even multiple of 128 bits? I am working with packets of data and do not want to change the size of my packet when encrypting it, yet my data is not an even multiple of 128? Does the AES block cipher allow handling of a final block that is short without changing the size of my message once encrypted? 回答1: That kind of detail depends on the chaining mode which you use. The chaining

When encrypting data that is not an even multiple of the block size do I have to send a complete last block?

耗尽温柔 提交于 2020-02-02 07:14:40
问题 If I am using a block cipher such as AES which has a block size of 128 bits, what do I do if my data is not an even multiple of 128 bits? I am working with packets of data and do not want to change the size of my packet when encrypting it, yet my data is not an even multiple of 128? Does the AES block cipher allow handling of a final block that is short without changing the size of my message once encrypted? 回答1: That kind of detail depends on the chaining mode which you use. The chaining

Add IV to beginning of CryptoStream

十年热恋 提交于 2020-02-01 09:08:06
问题 I'm implementing local encryption within an existing file management program. Much of the example code I can find, such as Microsoft's, demonstrates how to write directly to a file, but what I need to do is provide a stream that is consumed elsewhere in the program: CryptoStream GetEncryptStream(string filename) { var rjndl = new RijndaelManaged(); rjndl.KeySize = 256; rjndl.BlockSize = 256; rjndl.Mode = CipherMode.CBC; rjndl.Padding = PaddingMode.PKCS7; // Open read stream of unencrypted

AES Interoperability between PHP, Java, Javascript

痴心易碎 提交于 2020-02-01 08:46:07
问题 I'm developing a HTTP API that requires encryption. I have tried to use AES to get compatibility between Java, PHP and Javascript, but so far I have managed to get Java<->PHP and then Java<->Javascript, but not both PHP and Javascript at the same time. Has anyone had any experience with achieving interoperability between these languages and more? Any advice would be much appreciated. Thanks 回答1: To get AES to work across different systems, you have to make sure that everything is the same on

AES Interoperability between PHP, Java, Javascript

匆匆过客 提交于 2020-02-01 08:45:07
问题 I'm developing a HTTP API that requires encryption. I have tried to use AES to get compatibility between Java, PHP and Javascript, but so far I have managed to get Java<->PHP and then Java<->Javascript, but not both PHP and Javascript at the same time. Has anyone had any experience with achieving interoperability between these languages and more? Any advice would be much appreciated. Thanks 回答1: To get AES to work across different systems, you have to make sure that everything is the same on

Is there an AES library for clojure?

。_饼干妹妹 提交于 2020-02-01 02:21:09
问题 Is there an AES encryption library for clojure? should I use a java libray available through maven or clojars? Thank your for your time and consideration. 回答1: Here is a perhaps more idiomatic example using the available java crypto libraries. encrypt and decrypt here each simply take input text and the encryption key, both as Strings. (import (javax.crypto Cipher KeyGenerator SecretKey) (javax.crypto.spec SecretKeySpec) (java.security SecureRandom) (org.apache.commons.codec.binary Base64))

IllegalBlockSize Exception When Doing RSA on bytes of Strings

試著忘記壹切 提交于 2020-01-31 20:06:34
问题 I am trying to write RSA encryption and decryption classes in Java for a server where the client will be passing strings back and forth. I have the following code for the classes: public class RSAEncryption { public static final String KEYGENALGORITHM = "RSA"; public static final String ALGORITHM = "RSA/ECB/PKCS1Padding"; public static KeyPairContainer generateKey() { KeyPairGenerator keyGen; KeyPair key; try { keyGen = KeyPairGenerator.getInstance(KEYGENALGORITHM); keyGen.initialize(1024);