aes

Standard library for AES encryption for VB.NET?

谁说胖子不能爱 提交于 2019-11-30 14:28:26
问题 Is there a standard library to use for AES encryption for VB.NET? I want to encrypt a string with a static private key. I googled and found a lot of variations. I don't really know how to determine which algorithms are secure or not. 回答1: The System.Security.Cryptography namespace contains all the classes you need to perform most standard encryption tasks. Unfortunately, since encryption is a rather complicated topic, the classes are somewhat difficult to work with--especially for beginners.

Simple AES encryption using WinAPI

落爺英雄遲暮 提交于 2019-11-30 14:25:35
I need to do simple single-block AES encryption / decryption in my Qt / C++ application. This is a "keep the honest people honest" implementation, so just a basic encrypt(key, data) is necessary--I'm not worried about initialization vectors, etc. My input and key will always be exactly 16 bytes. I'd really like to avoid another dependency to compile / link / ship with my application, so I'm trying to use what's available on each platform. On the Mac, this was a one-liner to CCCrypt . On Windows, I'm getting lost in the API from WinCrypt.h . Their example of encrypting a file is almost 600

encrypting and/or decrypting large files (AES) on a memory and storage constrained system, with “catastrophe recovery”

梦想的初衷 提交于 2019-11-30 14:22:32
问题 I have a fairly generic question, so please pardon if it is a bit vague. So, let's a assume a file of 1GB, that needs to be encrypted and later decrypted on a given system. Problem is that the system has less than 512 mb of free memory and about 1.5 GB storage space (give or take), so, with the file "onboard" we have about ~500 MB of "hard drive scratch space" and less than 512 mb RAM to "play with". The system is not unlikely to experience an "unscheduled power down" at any moment during

Java AES: No installed provider supports this key: javax.crypto.spec.SecretKeySpec

帅比萌擦擦* 提交于 2019-11-30 13:59:31
问题 I'm trying to set up 128 bit AES encryption, and I'm getting an exception thrown on my Cipher.init: No installed provider supports this key: javax.crypto.spec.SecretKeySpec I'm generating the Key on the client side using the following code: private KeyGenerator kgen; try { kgen = KeyGenerator.getInstance("AES"); } catch (NoSuchAlgorithmException e) { // TODO Auto-generated catch block e.printStackTrace(); } kgen.init(128); } SecretKey skey = kgen.generateKey(); This key is then passed to the

AES Encryption Java Invalid Key length

旧时模样 提交于 2019-11-30 13:21:51
问题 I am trying to create an AES encryption method, but for some reason I keep getting java.security.InvalidKeyException: Key length not 128/192/256 bits Here is the code: public static SecretKey getSecretKey(char[] password, byte[] salt) throws NoSuchAlgorithmException, InvalidKeySpecException{ SecretKeyFactory factory = SecretKeyFactory.getInstance("PBEWithMD5AndDES"); // NOTE: last argument is the key length, and it is 256 KeySpec spec = new PBEKeySpec(password, salt, 1024, 256); SecretKey tmp

python Crypto 加密解密

北城以北 提交于 2019-11-30 12:27:37
本片文字记录使用python 的Crypto 工具对图片或者文本进行加密解密的方法: import numpy as np from PIL import Image from base64 import b64encode, b64decode from Crypto.Cipher import AES BS = 16 iv = 16 * b'\0' key = b'25jkUjx14hkc@q58gxU3mcaaaaaaaaaa' imgPath = './test/data/0_biaoge.jpg' # pad for length not multiple of string pad_txt = lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS) # jiami obj = AES.new(key, AES.MODE_CBC, iv) img = open(imgPath, 'rb').read() img_base64 = b64encode(img) img_base64_str = str(img_base64, encoding='utf-8') data_jiami = obj.encrypt(pad_txt(img_base64_str)) # jiemi obj2 = AES.new(key,

Java AES without padding

只愿长相守 提交于 2019-11-30 12:25:35
问题 What are some of the simplest ways to AES encrypt and decrypt a 16 byte array without the automatic padding? I have found solutions that use external libraries, but I want to avoid that if possible. My current code is SecretKeySpec skeySpec = new SecretKeySpec(getCryptoKeyByteArray(length=16)); // 128 bits Cipher encryptor = Cipher.getInstance("AES"); encryptor.init(Cipher.ENCRYPT_MODE, skeySpec); byte[] encrypted = encryptor.doFinal(plain); How can I prevent the padding? The plain data is

How to decrypt the first message sent from Mifare Desfire EV1

柔情痞子 提交于 2019-11-30 11:56:57
问题 Does anyone have a clue how to decrypt the first message sent from the card? I mean after the authentication success and then you send a command (for example 0x51 (GetRealTagUID). It returns 00+random32bits (always different). I try to decrypt it with: private byte[] decrypt(byte[] raw, byte[] encrypted, byte[] iv) throws Exception { IvParameterSpec ivParameterSpec = new IvParameterSpec(iv); SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES"); Cipher cipher = Cipher.getInstance("AES/CBC

Cryptography: best practices for keys in memory?

◇◆丶佛笑我妖孽 提交于 2019-11-30 11:56:37
Background: I got some data encrypted with AES (ie symmetric crypto) in a database. A server side application, running on a (assumed) secure and isolated Linux box, uses this data. It reads the encrypted data from the DB, and writes back encrypted data, only dealing with the unencrypted data in memory. So, in order to do this, the app is required to have the key stored in memory. The question is, is there any good best practices for this? Securing the key in memory. A few ideas: Keeping it in unswappable memory (for linux: setting SHM_LOCK with shmctl(2) ?) Splitting the key over multiple

invalid AES key length error

╄→гoц情女王★ 提交于 2019-11-30 11:23:00
问题 this code give invalid AES key length error. how can i correct it ? ( i want 128 bit key AES encryption ) package org.temp2.cod1; import java.security.*; import javax.crypto.*; import javax.crypto.spec.*; import java.io.*; public class Code1 { public static void main(String[] args) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException { String s = "9882623867"; byte[] plaintext = s.getBytes(