encryption-symmetric

javax.crypto.Cipher equivalent code in Nodejs Crypto Javascript

别来无恙 提交于 2019-12-04 19:10:09
I'm trying to convert below java code into nodejs. public static String encrypt(String accessToken) throws Exception { Cipher cipher = Cipher.getInstance("AES"); String merchantKey = "11111111111111111111"; String st = StringUtils.substring(merchantKey, 0, 16); System.out.println(st); Key secretKey = new SecretKeySpec(st.getBytes(), "AES"); cipher.init(Cipher.ENCRYPT_MODE, secretKey); byte[] encryptedByte = cipher.doFinal(accessToken.getBytes()); // convert the byte to hex format StringBuffer sb = new StringBuffer(); for (int i = 0; i < encryptedByte.length; i++) { sb.append(Integer.toString(

How should I derive the key and initialization vector for my AES encrypted database entries?

本秂侑毒 提交于 2019-12-04 15:48:52
I've built a CMS system to allow users to create and manage online forms on my client's intranet app. Of course some of the data handled by the forms may need to be encrypted e.g. if the system is used to build a form that handles salary specifics or whatever. So I'm using the AESManaged class to symmetrically encrypt this sort of data prior to it going into our application db. All is fine, but now, prior to release, I could do with a steer regarding the shared secret and salt . My original idea was to make a (dynamic) shared secret by combining the (GUID-based) ID of the Form containing the

Is there two key symetric commutative encryption function?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 14:36:39
I'm wondering if there is some strong (like AES or so.) encryption function that works like this: symetric 2 keys: plaintext -> 2keys ->ciphered text, however it must not matter order of keys, i.e Key1 (Key2 (plaintext)) == Key2 (Key1(plaintext)) e.g. "commutative" (also required for decryption - you need two keys, doesn't matter order) thanks It's not a commutative encryption, but there are well-proven algorithms for secret sharing (note, this is not the same thing as "key agreement.") Two of the best known methods are Shamir's and Blakley's. In general, these algorithms take a secret and

AES 256 Encryption with PyCrypto using CBC mode - any weaknesses?

只谈情不闲聊 提交于 2019-12-04 14:08:10
I have the following python script to encrypt/decrypt data using AES 256, could you please tell me if there's anything in the code that may make the encryption weak or if there's anything that I've not taken account of for AES 256 encryption using CBC mode? I've tested the script and it works fine, it is encrypting and decrypting data but just wanted a second opinion. Thanks. from Crypto.Cipher import AES from Crypto import Random BLOCK_SIZE = 32 INTERRUPT = u'\u0001' PAD = u'\u0000' def AddPadding(data, interrupt, pad, block_size): new_data = ''.join([data, interrupt]) new_data_len = len(new

Using Rijndael encryption for large files

心已入冬 提交于 2019-12-04 11:35:42
问题 I'm in a situation where I need to encrypt / decrypt a file of n length securely, ideally using Rijndael, but definitely at 256bit encryption. I've played around with encryption before and have encrypted/decrypted strings and byte arrays quite happily. However, because I don't know the size of the file (and it's very feasible that the files in question could be quite large (~2.5gb) I can't just load them up into a byte array and enc/decrypt them in a single bound as I have before. So, after a

How strong is this hashing technique?

六眼飞鱼酱① 提交于 2019-12-04 10:50:56
Use AES/Rijndael or any symmetric encryption. Encrypt the hidden value using itself as the key and a random IV. Store the ciphertext + IV. Discard everything else. To check the hash: try to decrypt using provided plaintext. If provided == decrypted, then it's OK. Ignore ciphertext length problems. Is this secure? As described, it has a problem in that it reveals information about the length of the data being hashed. That in itself would be some kind of weakness. Secondly ... it is not clear that you would be able to check the hash. It would be necessary to store the randomly generated IV with

Where to Store Encryption Keys MVC Application

牧云@^-^@ 提交于 2019-12-04 10:32:08
问题 I am using a AES encryption/decryption class that needs a key value and vector value encrypt and decrypt data in an MVC3 application. On saving the record I am encrypting the data then storing in a database. When i retrieve the record i am decrypting in the controller and passing the unencrypted value to the view. The concern is not protecting data as it traverses the network but to protect the database should it be compromised. I have read many posts that say dont put the keys for encryption

How can I create a shared-secret voucher code system between 2 independent servers?

折月煮酒 提交于 2019-12-04 09:56:27
Given this workflow: Server A User authenticates. User purchases randomly generated unique voucher code using shared secret to use an application on on server B. Server B User authenticates. User inputs voucher code. Server B validates code is legitimate using shared secret Server B grants access to the application. I need a way in PHP to implement the functions generateVoucherCode and validateVoucherCode as shown below: Server A $voucher = generateVoucherCode("someSharedSecret"); Server B $isValid = validateVoucherCode($userInputtedCode, "someSharedSecret"); if($isValid) { // allow access to

Best practices for (symmetric) encryption in .Net?

扶醉桌前 提交于 2019-12-04 08:09:21
问题 What is considered "best practice" for encrypting certain sensitive or personally identifiable data in a SQL database (under PCI, HIPAA, or other applicable compliance standards)? There are many questions here regarding individual aspects of a solution, but I have not seen any that discuss the approach at a high level. After looking around for quite some time, I came up with the following: Use CryptoAPI and Rijndael Generate IV and store it with the encrypted data Use DPAPI (Machine scope) to

How to decrypt a string encrypted by V FoxPro

不想你离开。 提交于 2019-12-04 06:20:08
问题 I have a program built in Visual Fox Pro which read and write information in a database, but the information is encrypted. I have the source code so, I have the key (same key to encrypt and dencrypt) use to encrypt/decrypt. But I cannot get the algorithm used to encrypt/dencrypt. I need this in order to create a new program with C# which can read the information and save it in another DB. Below you have some examples of the information encrypted: ùœ¢Qa³•ù¼?- pJ´’ˆò»Æ8-skYIÞµ§¬†Œ‚„Šç ëŸ