aes

KMS密钥管理服务(Hadoop)

烈酒焚心 提交于 2019-12-06 21:12:46
##前言 KMS 是Hadoop下的一个密钥管理服务,它实际是与Hadoop结合,提供HDFS文件做AES加密用的。所以它是用来存储AES秘钥的,AES提供三种位数的秘钥,分别是 128 , 192 , 256 ,所以KMS只能存储这三种位数的 byte 数组。 如果你是为了给HDFS文件加密,那么直接通过配置就可以完成,它与Hadoop能够完美契合,由Hadoop调用自动产生秘钥并管理秘钥。但是HDFS文件加密粒度太粗,我们的数据并非要全部加密,而当前针对Hive表列的加密并没有集成方案,官方提供了AES的encrypt函数,但是秘钥key还需明文传入。这样对集群来说其实很不安全。 如果我们自己实现加密UDF,然后借用KMS来做密钥管理,在KMS上加上Kerberos认证,秘钥的处理就可以都封装在UDF内部,不对外暴露,而且可以实现身份认证。 KMS本身提供了一系列API来创建,获取和维护密钥,官网介绍中主要以 RESTFUL 的形式提供,但如果集群上了Kerberos,请求的认证在RESTFULL里就不好做(具体没操作过)。在Hadoop源码里,提供了 KMSClientProvider 用于Hadoop的加密,所以我们可以利用这个接口来获取KMS服务,实现创建管理密钥。 ##配置 KMS是一个Web服务,只需要在一台机器上配置即可,其主要配置文件是 kms-site.xml

ImportError: No module named Crypto

血红的双手。 提交于 2019-12-06 17:13:54
问题 I am just starting to explore Python. I am trying to run an AES algorithm code and I am facing the: ImportError: No module named Crypto. How do you solve this? 回答1: You have to install crypto package. https://pypi.python.org/pypi/pycrypto 回答2: Solution : By installing pycrypto module from your virtualenv pip install pycrypto 回答3: Solved when i installed pycrypto rather then crypto pip2 install pycrypto 来源: https://stackoverflow.com/questions/30738083/importerror-no-module-named-crypto

algorithm - Is the RijndaelManaged Class in C# equivalent to AES encryption?

自作多情 提交于 2019-12-06 16:55:41
问题 I am asking this question to confirm whether the RijndaelManaged class in C# is equivalent to AES encryption. From what I have been reading, RijndaelManaged was the algorithm of choice to implement AES encyrption. Can someone confirm this please? Is RijndaelManaged algorithm safe to be used for a web project? Thanks :) 回答1: The AES algorithm was selected in a competition held by NIST between 1997 and 2000. The winner was an algorithm called Rijndael. NIST specified that the AES algorithm was

How can i decrypt the xml file in iOS with AES/CBC/PKCS5Padding standard,in android the file has been decrypted ,all keys like salt, IV

北城余情 提交于 2019-12-06 16:24:21
问题 private static Cipher getCipher(int mode) throws Exception { Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding"); //a random Init. Vector. just for testing byte[] iv = "e675f725e675f725".getBytes("UTF-8"); c.init(mode, generateKey(), new IvParameterSpec(iv)); return c; } private static String Decrypt(String encrypted) throws Exception { byte[] decodedValue = new Base64().decode(encrypted.getBytes("UTF-8")); // new BASE64Decoder().decodeBuffer(encrypted); Cipher c = getCipher(Cipher.DECRYPT

javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16 when decrypting with padded cipher in tcp

荒凉一梦 提交于 2019-12-06 16:20:53
问题 I am using this AES Encrption and decryption method for encrypting my data. There is no problem with udp but when i use tcp i get this error "javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16 when decrypting with padded cipher" AES Encryption/Decryption Code: public class AESEncDec { private static final String ALGO = "AES"; private static final byte[] keyValue = new byte[] { 'T', 'h', 'e', 'B','e', 's', 't','S', 'e', 'c', 'r','e', 't', 'K', 'e', 'y' }; public static

To use AES with 256 bits in inbuild java 1.4 api

╄→尐↘猪︶ㄣ 提交于 2019-12-06 16:00:09
问题 I am able to encrypt with AES 128 but with more key length it fails. code using AES 128 is as below. import java.security.*; import javax.crypto.*; import javax.crypto.spec.*; import java.io.*; /** * This program generates a AES key, retrieves its raw bytes, and * then reinstantiates a AES key from the key bytes. * The reinstantiated key is used to initialize a AES cipher for * encryption and decryption. */ public class AES { /** * Turns array of bytes into string * * @param buf Array of

How to switch from AES-256 to AES-128?

走远了吗. 提交于 2019-12-06 15:58:17
问题 There were many questions about AES, but I have the following problem. I'm currently using the following AES implementation to encrypt data byte [] PRFkey = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; byte [] plaintext = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; SecretKeySpec encryptionKey=new SecretKeySpec(PRFkey, "AES"); Cipher cipher=Cipher.getInstance("AES"); cipher.init(Cipher.ENCRYPT_MODE, encryptionKey); byte[] encryptedData=cipher.doFinal(plaintext); And it turned out that result is 32

Encrypt with Node.js AES CTR and decrypt with PyCrypto

喜夏-厌秋 提交于 2019-12-06 15:39:13
Okay, so basically I am having issues decrypting with Python. I've managed to encrypt/decrypt data with Node.js - using "aes-128-ctr", the same goes for PyCrypto, but when I try to encrypt with Node.js and decrypt with Python I get invalid deciphered text. Node.js code: var key = "1234567890123456"; var cipher = crypto.createCipher("aes-128-ctr",key) var ctext = cipher.update('asasasa','utf8','hex') + cipher.final('hex') console.log(ctext) // outputs: "f2cf6ecd8f" Python code: counter = Counter.new(128) cipher = AES.new("1234567890123456", AES.MODE_CTR, counter=counter) cipher.decrypt(

how to match IV in AESCrypt with JAVA and RUBY

自作多情 提交于 2019-12-06 14:54:28
问题 I put the Encrypted ID and Nickname to Database. but there is a problem when I need to get the ID and nickname in ruby because AESCrypt in ruby doesn't work. I think the problem is IV that isn't same with ruby and java here is I used in java code (actually in android) public class AESCrypt { private final Cipher cipher; private final SecretKeySpec key; private AlgorithmParameterSpec spec; public AESCrypt(String password) throws Exception { // hash password with SHA-256 and crop the output to

C#编程之AES加密(三)

泪湿孤枕 提交于 2019-12-06 14:20:05
这一章我们将上一章的内容做进一步完善,由用户输入需要加密的序列号,进行加密: 因为我们输入的都是以字符的形式读取,所以第一步要将读取到的字符存入到数组中: char [] inputBuf = str.ToCharArray(); 之后对这个数组进行转换成16进制,例如输入A5两个字符,我们要将其转成16进制数,即为0xA5,并将其装入byte数组内。 if (inputBuf[j] >= '0' && '9' >= inputBuf[j]) outBuf[i] = (byte)(inputBuf[j++] - '0'); else if (('f' >= inputBuf[j]) && (inputBuf[j] >= 'a')) outBuf[i] = (byte)(inputBuf[j++] - 0x57); else if (('F' >= inputBuf[j]) && (inputBuf[j] >= 'A')) outBuf[i] = (byte)(inputBuf[j++] - 0x37); else throw new Exception("ERROR: Format incorrect."); outBuf[i] <<= 4; if (inputBuf[j] >= '0' && '9' >= inputBuf[j]) outBuf[i] |= (byte)